Unix Interview Questions
A list of top frequently asked Unix interview questions and answers are given below.
1) What is Unix?
UNIX is a portable operating system that is designed for efficient multitasking and multi-user functions. Since it is a portable operating system, it can run on different hardware platforms. It is written in C language. It was developed by Ken Thompson, Dennis Ritchie, Douglas McIlroy, and Joe Ossanna.
2) List the distributions of UNIX.
UNIX has many distributions including Solaris UNIX, AIX, HP UNIX and BSD and many more.
3) List some features of UNIX.
UNIX includes the following features:
UNIX supports the multiuser system: In UNIX it is possible that many users can use the system with their separate workspace and logins i.e.it has full support for the multiuser environment.
UNIX supports the multitasking environment: In UNIX many apps can run at a single instance of time this is also known as a multitasking environment.
4) What are the core concepts of UNIX
The core concepts of UNIX are given below.
5) What is a UNIX shell?
The UNIX shell is a program which is used as an interface between the user and the UNIX operating system. It is not a part of the kernel, but it can communicate directly with the server.
6) What is filter?
A filter is a program that takes input from standard inputs and performs some operation on that input to produce a result as standard output.
7) What are the devices represented in UNIX?
All devices in UNIX are represented by particular files that are located in /dev directory.
8) Is there any method to erase all files in the current directory, along with its all sub-directories, by using only one command?
Yes, you should use "rm-r*" command for this purpose.
Here, the "rm" command is used for deleting files, the -r option will erase directories and subdirectories with their internal data and * is used for selecting all entries.
9) What is necessary before running a shell script from the terminal?
You must make the shell script executable by using the UNIX "chmod" command.
10) How to terminate a shell script if statement?
A shell script if statement can be terminated by using "fi."
11) Write down some common shells with their indicators?
12) What are the main features of Korn Shell?
13) What is the difference between cat command and more command?
The cat command is used to display the file contents on the terminal, whereas more command is used like a pager which displays the screen page by page If the file is large and you have to scroll off the screen before you view it.
14) Which command is used to restrict incoming messages?
The "mesg" command is used to restrict incoming messages.
15) Which command is used to kill the last background job?
The "kill $!" Command is used to kill the last background job.
16) Which data structure is used to maintain the file identification?
The "inode" data structure is used to maintain the file identification. Each file has a separate inode and a unique inode number.
17) What a pipe?
A pipe is used to join two or more commands by using a pipe "I" character. The output of the first command is propagated to the second command through the pipe.
18) What are the links and symbolic links in a UNIX file system?
A link is a second name for a file. Links are used to assign more than one name to a file, but cannot be used to designate a directory more than one name or link filenames on different computers.
Symbolic links are the files that only contain the name of another file. The operations on the symbolic link are directed to the file pointed by it. Both the limitations of connections are eliminated in symbolic links.
19) Explain system bootup in UNIX.
System bootup is the first thing that takes place when the power button is pressed in UNIX. Whenever the power button is pressed, BIOS is fired up and checks if all the hardware connected to the system are working correctly, after being successful the system asks the user to provide authentication.
20) How to change the password in UNIX operating system?
To change the password in UNIX operating system :
21) How to list directories in UNIX?
Command ls can be used to list directories in command prompt. Also, we can also use a variety of ls commands like:
22) How to check the date in UNIX?
To display the date in UNIX use the date command in command prompt.
23) How to log out in UNIX?
To log out of UNIX type the logout command in the command prompt.
24) How to perform a system shutdown in UNIX?
To perform system shutdown in UNIX, you can use the following commands:
25) How many types of files are there in UNIX?
There are three kinds of files in UNIX:
26) What are hidden files in UNIX?
Hidden files in UNIX are the files which have a .(dot) before the file name. These files do not show up in the traditional file manager.
Common examples of hidden files are:
27) What is the difference between a single dot and double dot in UNIX?
.(Single dot)-represents the current directory
..(Double dot)-represents the parent directory.
28) How to create files in UNIX?
Creating files in UNIX is simple. The User needs to use the vi editor to create new files.
Type vi filename in command prompt to create new files. We can also use the touch command to create a zero byte file.
29) How to display the contents of a file?
The user can use the cat command followed by the filename to display the command of a file. This command should be entered in the command prompt. The syntax of the command is shown below.
$ cat filename
Where the cat is the command to view contents of the file specified by the filename. Also if you want the line number to be displayed along with the content, you can use cat command with option -b.
30) How to calculate the number of words in a file?
To count the number of words in a file, Use the following command.
$ wc filename
Where wc is the command to count the number of words in the file specified by filename.
31) How to create a blank file in UNIX?
Blank files can be created by using the touch command, the syntax for the touch command is as follows:
$ touch filename
32) How to know the present working directory in UNIX?
To know the present working directory, Run the following command on the terminal.
33) How to know the information about a file?
To fetch the information about a file, use the following command.
$ file filename
34) How to change the directory in UNIX?
To change the directory, you can use the cd command in the terminal window. It changes the current directory to the specified directory.
$ cd directory-name
35) How to move files from one directory to other in UNIX?
In UNIX, mv command is used to move the file from one directory to some other directory.
$ mv <file-name> <destination path>
36) How to copy files from one directory to other in UNIX?
In UNIX, cp command is used to copy a file from one directory to some other directory. The syntax of the cp command is given below.
$ cp -r source filename destination file name.
The -r is used to copy all the content of a directory including sub-directories recursively.
37) How to remove files in UNIX?
To remove files, you can use the rm command. The syntax of the rm command is given below.
$ rm <filename>
we can use -r with the rm command to delete all the sub-directories recursively.
38) How to make a new directory in UNIX?
To make a new directory, you can use the mkdir command.
$ mkdir <directory-name>
39) How to remove the directory in UNIX?
To remove the directory, you can use the rmdir command. To use this command, use the following syntax.
$ rmdir filename.