Blog Archive

Theme images by Storman. Powered by Blogger.

Wednesday, July 20, 2016

Latest Unix Interview Questions and Answers For Freshers And Experienced.

Latest Unix Interview Questions and Answers For Freshers And Experienced. Unix Interview Questions For Freshers. Frequently Asked Unix Interview Questions and Answers.

There are multiple shell types of Unix. What are the features of the Bourne and Korn shell?

The Bourne shell is the standard shell of Unix. It provides the following features:

It gives the ability of input/output redirection.
Allows the usage of metacharacters for file name abbreviations.
The environment can be customized using the shell variables.
It provides the user with a built in command set for the creation of shell programs.
Allows the user to control a job.

The Korn shell is an extension of the Bourne shell which is backward compatible. The feature unique to the Korn shell are as follows:

Allows the user to do command line editing.
It maintains a command history, which enables the user to check the last commands executed.
There is a provision for integer arithmetic.
Provides the support for arrays and arithmetic expressions.
Give the user the option to use aliases which is used to abbreviate the command name.

What do you understand by File modes in Unix?

Unix enables the user to set the desired level of privacy. It allows the user to set the access permission of the file. This is know as the file mode of a file. 

The file permissions of file are displayed in the form :

drwxrwxrw filename date time

The letters r means read, w means write and x means execute.

When the permission of a file is set by the user it is necessary to classify the users into three categories:

Owner: the user who creates the file.
Group: other users having the same permissions as the group owner.
other: all other users. 

In the text drwxrwxrw the d letter signifies the directory.
Following the d letter the next three letters specify the permissions of the owner. the next three specify the permissions of the group. The last three characters specify the permissions of the other users.

What is the alias mechanism in UNIX?

The alias command allows the user to specify or assign another name to a command. It can be also used to club together a group of commands. 

For ex.

alias dir ‘ls -sFC’

The above command on being executed would tell the shell that dir is another name for the command ls -sFC. In this way, the user can simply assign an alias name to a command that could be difficult to remember. Now the user simply needs to use the specified alias name as given by him in place of the command for the same effect as the code.

The user can check the number of aliases active by typing in the command from the shell:

uhunix% alias pwdls ‘pwd; ls -sFC’

What are the different ways of redirecting I/O?

Unix allows the user to redirect the output of an operation instead of sending it to your screen. The user has to make used of the redirection pointer (> & >>). The various ways of redirecting the output are as follows:

To copy the contents of one file to another:

uhunix% cat file1> file2

To concatenate multiple files:

uhunix% cat file1 file2 file3 > newfile

To append a file to another file:

uhunix% cat bottomfile >> appendeefile

To redirect the input from instead of the keyboard to a file:

uhunix% mail username < letterfile

What are the uses of pipes in UNIX?

Piping in unix allows the user to set the output of a specific operation as input to another. The piping of output from one file to another is performed by using the | symbol. 

For ex.

uhunix% w | grep username

This command would allow the user to check if the specified user is logged in or not. When pipes are used in combination with redirection it gives the user the powerful ability to manipulate long operations in short steps. 

For ex.

uhunix% ls | grep vi > vi.files

This command would result in the creation of a vi.files which would consist of the names of all the files in the current directory with a vi in their names.
What steps does the shell take after processing a command.

Once a command line is terminated by the key the shell continues to process the command line in passes. 

Parsing: The for the shell is to separate the commands line into words. For this it uses the references of spaces and delimiters specified by the user. Any consecutive spaces are replaced by a single space unless specified.

Identifying variables: Any word preceded by a $ sign are treated as variables unless specified so.

Substitution: Any command surrounded by back quotes are executed by the shell and replaces the command with the output given.

Wild card recognition: After all the above tasks are completed the shell looks for wild card symbols in the command line.

What are the possible return values of kill()?

The kill() method on execution can yield the following possible results:

‘0’ returned: Means that the process exists with the specified PID. It will allow the user to send signals to this process.

‘-1’ returned, ‘errno==ESRCH’: This means that the process with the specified PID does not exist or some security enhancements is denying its existence.

‘-1’ returned, ‘errno==EPERM’: This means that the system would not permit the process to be killed.
The EPERM process is used to detect if a process exists or not. Any other error would specify that the process does not exist.

What is the super block in UNIX?

The file system of a system is described by a system block. Right at the beginning the super block is built when the file system is being created. The purpose of the super block is to contain the basic parameters of a system, for eg, the number of blocks and a count of the total number of files.

There are two superblocks:

The default super block is always present at a fix offset from the beginning of the system`s disk partition.
The redundant super block is not usually referenced unless the default superblock is effected by some error or system crash.

The file system consists of files. Some files may be categorized as directories which in itself contains the pointers to files that are themselves directories or files. Every file has a descriptor known as the inode. The inode describes the ownership information of a file.

How can non printable characters be shown in unix?

A file sometimes may contain non printable characters such as line breaks for windows. Most of the editors used with unix do not display these non-printable characters. In case the user wants to view these characters he has to use the vim -b command to see and edit these characters. The -b flag used after vim is used to force the vim to use the binary mode. 

For ex.

% cat foo.txt

% vim -b foo.txt

What are the types of path names that can be used in Unix?

In a file system which contains a hierarchy of directories the user has to specify a path to a file or directory to access it. 

For ex.


The above path refers to the file text.notes inside the folder which is inside the lyrics folder. The lyrics folder is contained by the music folder which in turn is contained by the my folder. The root directory is home.

There are two types of paths that can be used in Unix:

Absolute Path name: This type of file name starts with the "/" symbol i.e. the root.
Relative Path name: This path name begins from the current working directory where the user is. 

For the above stated path the relative directory would be:


0 on: "Latest Unix Interview Questions and Answers For Freshers And Experienced."