Unix Interview Questions Preparation Course


This course contains Top 50 Unix interview questions that are asked in a technical interview. The focus is on commands and concepts inside Unix. It is an important topic for a software developer to know about Unix.

It is a compilation of advanced Unix interview questions after attending dozens of technical interviews in top-notch companies like- Oracle, Google, Ebay, Amazon etc. Each question is accompanied with an answer so that you can prepare for job interview in short time.

Often, these questions and concepts are used in our daily programming work. But these are most helpful when an Interviewer is trying to test your deep knowledge of Unix concepts.

Join the Unix Interview Questions Preparation Course now.

What are the topics covered in this course?

We cover a wide range of topics in this course. We have questions on Unix commands, concepts etc.

How will this course help me?

By attending this course, you do not have to spend time searching the Internet for Unix interview questions. We have already compiled the list of the most popular and the latest Unix Interview questions.

Are there answers in this course?

Yes, in this course each question is followed by an answer. So you can save time in interview preparation.

What is the best way of viewing this course?

You have to just watch the course from beginning to end. Once you go through all the videos, try to answer the questions in your own words. Also mark the questions that you could not answer by yourself. Then, in second pass go through only the difficult questions. After going through this course 2-3 times, you will be well prepared to face a technical interview in Unix topic.

What is the level of questions in this course?

This course contains questions that are good for a Fresher to an Architect level. The difficulty level of question varies in the course from a Fresher to an Experienced professional.

What are the sample questions covered in this course?

Sample questions covered in this course are as follows:

  1. How will you remove all files in current directory? Including the files that are two levels down in a sub-directory.
  2. What is the difference between the –v and –x options in Bash shell scripts?
  3. What is a Filter in Unix command?
  4. What is Kernel in Unix operating system?
  5. What is a Shell in Unix OS?
  6. What are the different shells in Unix that you know about?
  7. What is the first character of the output in ls –l command ?
  8. What is the difference between Multi-tasking and Multi-user environment?
  9. What is an Inode in Unix?
  10. What is the difference between absolute path and relative path in Unix file system?
  11. What are the main responsibilities of a Unix Shell?
  12. What is a Shell variable?
  13. What are the important Shell variables that are initialized on starting a Shell?
  14. How will you set the value of Environment variables in Unix?
  15. What is the difference between a System Call and a library function?
  16. What are the networking commands in Unix that you have used?
  17. What is a Pipeline in Unix?
  18. What is the use of tee command in Unix?
  19. How will you count the number of lines and words in a file in Unix?
  20. What is Bash shell?
  21. How will you search for a name in Unix files?
  22. What are the popular options of grep command in Unix?
  23. What is the difference between whoami and who am i commands in Unix?
  24. What is a Superuser in Unix?
  25. How will you check the information about a process in Unix?
  26. What is the use of more command with cat command?
  27. What are the File modes in Unix?
  28. We wrote a shell script in Unix but it is not doing anything. What could be the reason?
  29. What is the significance of 755 in chmod 755 command?
  30. How can we run a process in background in Unix? How can we kill a process running in background?
  31. How will you create a read only file in Unix?
  32. How does alias work in Unix?
  33. How can you redirect I/O in Unix?
  34. What are the main steps taken by a Unix Shell for processing a command?
  35. What is a Sticky bit in Unix?
  36. What are the different outputs from Kill command in Unix?
  37. How will you customize your environment in Unix?
  38. What are the popular commands for user management in Unix?
  39. How will you debug a shell script in Unix?
  40. What is the difference between a Zombie and Orphan process in Unix?
  41. How will you check if a remote host is still alive?
  42. How will you get the last executed command in Unix?
  43. What is the meaning of “2>&1” in a Unix shell?
  44. How will you find which process is taking most CPU time in Unix?
  45. What is the difference between Soft link and Hard link in Unix?
  46. How will you find which processes are using a file?
  47. What is the purpose of nohup in Unix?
  48. How will you remove blank lines from a file in Unix?
  49. How will you find the remote hosts that are connecting to your system on a specific port in Unix?
  50. What is xargs in Unix?

How will you find which process is taking most CPU time in Unix?

In Unix, we can use top command to list the CPU time and memory used by various processes. The top command lists the process IDs and CPU time, memory etc used by top most processes.

Top command keeps refreshing the screen at a specified interval. So we can see over the time which process is always appearing on the top most row in the result of top command.

This is the process that is consuming most CPU time.

What is the difference between Soft link and Hard link in Unix?

A soft link is a pointer to a file, directory or a program located in a different location. A hard link can point to a program or a file but not to a directory.

If we move, delete or rename a file, the soft link will be broken. But a hard link still remains after moving the file/program.

We use the command ln –s for creating a soft link. But a hard link can be created by ln command without –s option.

How will you find which processes are using a file?

We can use lsof command to find the list of Process IDs of the processes that are accessing a file in Unix.

Lsof stands for List Open Files.

Sample command is
:
% lsof /var

It will list the processes that are accessing /var directory in current unix system.

We can use options –i, -n and –P for different uses.

% lsof –i will only list IP sockets.

What is the purpose of nohup in Unix?

In Unix, nohup command can be used to run a command in background. But it is different from & option to run a process in background.

Nohup stands for No Hangup. A nohup process does not stop even if the Unix user that started the process has logged out from the system.

But the process started with option & will stop when the user that started the process logs off.

How will you remove blank lines from a file in Unix?

We can use grep command for this option. Grep command gives –v option to exclude lines that do not match a pattern.

In an empty line there is nothing from start to end. In Grep command, ^ denotes that start of line and $ denotes the end of line.

% grep –v ‘^$’ lists the lines that are empty from start to the end.

Once we get this result, we can use > operator to write the output to a new file. So exact command will be:

% grep –v ‘^$’ file1.txt > file2.txt

How will you find the remote hosts that are connecting to your system on a specific port in Unix?

We can use netstat command for this purpose. Netstat command lists the statistics about network connections. We can grep for the port in which we are interested.

Exact command will be
:
% netstst –a | grep “port number”

What is xargs in Unix?

We use xargs command to build and execute commands that take input from standard input. It is generally used in chaining of commands.

Xargs breaks the list of arguments into small sub lists that can be handled by a command.

Following is a sample command
:

% find /path -type f -print | xargs rm

The above command uses find to get the list of all files in /path directory. Then xargs command passes this list to rm command so that they can be deleted.

What is the meaning of “2>&1” in a Unix shell?

In Unix shell file descriptor 1 is for standard output.
File description 2 is for standard error.

We can use “2>&1” in a command so that all the errors from standard error go to standard output.

% cat file 2>&1

How will you check if a remote host is still alive?

We can use one of the networking commands in Unix. It is called ping. With ping command we can ping a remote host.

Ping utility sends packets in an IP network with ICMP protocol. Once the packet goes from source to destination and comes back it records the time.

We can even specify the number of packets we want to send so that we collect more statistics to confirm the result.

% ping www.google.com

Another option is to use telnet to remote host to check its status.