Tutorial corner


Top unix interview question with answer :Part -3

Spread the love

Collection of Top unix interview question with answer . We just started with series of Unix interview question (with answer)  blogs. In  previous blogs ,”Top unix interview question with answer :Part -1” and  “Top unix interview question with answer :Part -2” , we go through some of the theory and command based unix interview questions with answer. Hope you enjoyed those questions and it must have boost up your unix skills. Here we are going to start with Part -3 of “Top unix interview question with answer” series.

Top unix interview question with answer

Top unix interview question with answer

Top Unix interview question with answer

Ques: What is the command to change the permission of file?

Ans : By using chmod command along with permission and filename as parameter.


To make a file read only use below command

chmod 400 filename

Ques: What command is used to set default permission of files in unix?

Ans : umask command

Ques: How to list down last modified 5 files in current directory?

Ans :

ls -t | head -5 
Explanation :
ls -t lists out all the files in the present directory in the order of modified date.

Use head -5 with a pipe symbol to get the top 5 lines.

Ques: How to to make hidden file in unix ?

Ans : Hidden files in unix is prefixed with “.” (dot) in filename  : Example .profile. It will be hidden wile normal listing of files

Ques: How to list down all hidden file in unix?

Ans: Using “-a”  or “-A” option in ls command.

ls -a  will list all hidden file along with current directory (./) and parent directory (../) ls -A will list only hidden files only.

Ques:  How to reverse a string in Unix?

Ans: Using “rev” command in unix.

Example :

echo "The 300" | rev
003 ehT

Ques. What difference between cmp and diff commands?

cmp – Compares two files byte by byte and displays the first mismatch

diff – tells the changes to be made to make the files identical

Ques: What is command to a string from lower case to upper case?

Ans : echo “Unix” | tr [a-z] [A-Z]

will print


Ques:  Write a command to convert a string to start with Init cap.

Ans : echo champion | awk ‘{print toupper(substr($1,1,1)) tolower(substr($1,2))}’

will print


Ques: What is the command to display free disk space on the UNIX file system?

Ans : df -lk

Ques: What will the be the output of  following command ?
$ echo *

Ans : * will be list of file to the echo command. Hence it will list all the files in current directory. (It will act as ls command here)

Ques: How to restrict incoming message in unix

Ans : By using “mesg” command.

Ques: How to count no of file in unix?

Ans : Using wc command with -l option

Example : wc -l filename.txt

Ques: What is difference between Hard Link and Soft Link in UNIX?

Ans :

Hard Link:
While creating a link from source to Destination file. —-> The changes done in the source file will be effected in destination file.
But when The source file is deleted the destination file remains the same.

Hard Link syntax: ln file1 file2

Soft Link:
While creating a link using soft link from source to destination file → the changes done in the source file will be effected in Destination file too.
But when the source file is deleted the destination file also gets invisible. i.e when u tried to check the destination file its says no such file or directory
Note: Its always best practice to give a hard link than soft link.

Soft link Syntax: ln -s file1 file2

Ques: What is /dev/null?

Ans. :  It is a blackhole. For example, in the earlier example, if you want to ignore error like “sh: cd: Temp: No such file or directory” being printed, you can redirect your output to /dev/null. For example

$ cd temp > /dev/null 2>&1

Ques: What is a zombie?

Ans: When a program forks and the child finishes before the parent, the kernel still keeps some of its information about the child in case the parent might need it – for example, the parent may need to check the child’s exit status. To be able to get this information, the parent calls `wait()’; In the interval between the child terminating and the parent calling `wait()’, the child is said to be a `zombie’ (If you do `ps’, the child will have a `Z’ in its status field to indicate this.)

Ques: What is !! command in UNIX?

Ans : This will repeat the last command run on the current session

Also check below

Top unix interview question with answer :Part –1

Top unix interview question with answer :Part –2

So in above article ,we have gone through some of the commonly asked unix interview question with answer.

The Author

Alisha Lamba

Hello Friends , I am Alisha Lamba .I love to write article on latest technologies like Informatica , ETL , data warehouse , SQL-PL SQL
Copyright 2015 - Tutorial Corner Frontier Theme