TOP 45 Best UNIX Interview Questions with Answers

Here are the most commonly asked UNIX Interview questions and answers:

The tutorial is about most commonly asked UNIX interview questions and answers. The main objective of the document is to measure the theoretical and practical knowledge on UNIX operating system.

UNIX is a computer operating system was developed at AT&T Bell Labs, Murray Hills, New Jersey in 1969.Unix is a portable operating system that allows running on different hardware systems.

It was written in C and designed to facilitate multi-tasking and multi-user functionalities in an efficient way.

Within this document, the main focus will go to theoretical parts and the most commonly use syntax with UNIX.

Best UNIX Interview Questions and Answers

UNIX Interview Questions And Answers

Let’s start.

Q #1) What is the description for Kernel?

Ans) Kernel is the master program with UNIX operating system that controls the resources of the computer. The resources allocation to different users and tasks handle by this section. Kernel do not have direct communication with the user and it starts separate interactive program call shell to each user when login to the system.

Q #2) What is a single user system?

Ans) A personal computer with an operating system which was designed to operate by a single user at a given time. Single user system becomes more popular since low-cost hardware and availability of wide range of software to perform difference tasks.

Q #3) What are the main features of UNIX?

  • Machine independent
  • Portability
  • Multi-user operations
  • Unix Shells
  • Hierarchical file system
  • Pipes and filters
  • Background processors
  • Utilities
  • Development tools.

Q #4) What is called Shell?

Ans) The interface between user and system called a shell. Shell accepts commands and set them to execute for user operations.

Q #5) What are the responsibilities of a shell?

  • Program Execution
  • Input/output redirection
  • Filename and variable substitution
  • Pipeline hookup
  • Environment control
  • Integrated programming language

Q #6) What is the general format of UNIX command syntax?

Ans) In general consideration, UNIX shell commands follows the following pattern

Command (-argument) (-argument) (-argument) (file name)

Q #7) Describe the usage and functionality of the command “rm –r *” in UNIX?

Ans) The command “rm –r *” is a single line command to erase all files in a directory with its subdirectories.

  • “rm” – Is for deleting files.
  • “-r”   – Is to delete directories and subdirectories with files within.
  • “*”     – Is indicate all entries.

Q #8) Describe the term directory in UNIX?

Ans) A specialized form of a file that maintains a list of all the files which include in it is called a directory. Each file assigns to a directory.

Q #9) Specify the difference between absolute path and related path?

Ans) Absolute path refers to the exact path as defined from the root directory. Related path refers to the path related to the current locations.

Q #10) What is the UNIX command to list files/folders in alphabetical order?

Ans) The ‘ls –l’ command is used to list down files and folders in alphabetical order. When you use ‘ls –lt’ is list down files /folders sorted with modified time.

Q #11) Describe links and symbolic links in UNIX?

Ans) The second name for a file called a Link. It is used to assign more than one name for a file. It is not valid to assign more than one name to a directory or to link filenames on different computers.

General command ‘– ln filename1 filename2’

A symbolic link is the files that use to contain only the name of other files include in it. Directed to the files pointed by it is the operation of the symbolic link.

General command ‘– ln -s filename1 filename2’

Q #12) What is the FIFO?

Ans) FIFO (First In First Out) is also called named pipes and it is a special file for date transient. Data is read only in the written order. This is use to inter-process communications, where data write to one end and reads from another end of the pipe.

Q #13) Describe fork() system call?

Ans) The command use to create a new process from an existing process is called fork().The main process is called parent process and new process id called child process. The parent gets the child process id returned and the child gets 0. The returned values are used to check which process which code executed.

The returned values are used to check which process which code executed.

Q #14) Explain the following sentence?

It is not advisable to use root as the default login.

Ans) The root account is very important and it can leads to system damage easily with abusive usage. So that the securities that normally apply to user accounts are not applicable to the root account.

Q #15) What is mean by Super User?

Ans) The user with access to all files and commands within the system is called super user. Generally, super user login is to root and the login is secured with the root password.

Q #16) What is process group?

Ans) A collection of one or more processes is called process group. There is a unique process id for each process group. The function “getpgrp” returns the process group ID for the calling process.

Q #17) What are the different file types available with UNIX?

  • Regular files
  • Directory files
  • Character special files
  • Block special files
  • FIFO
  • Symbolic links
  • Socket

Q #18) What is the behavioral difference between “cmp” and “diff” commands?

Ans) Both commands for file comparison.

Cmp – Compare given two files with byte by byte and display the first mismatch.

Diff – Display changes that need to done to make both file identical.

Q #19) What are the duties of following commands?

Ans) chmod, chown, chgrp

  • chmod – Change the permission set of the file.
  • chown – Change ownership of the file.
  • chgrp – Change group of the file.

Q #20) What is the command to find today’s date?

Ans) The command “date” use to retrieve current date.

date command

Q #21) What is the purpose of the following command?

README

Ans) The command is to display the first part of the file names README.txt which just fit as much as on one screen.

Q #22) Describe the zip/unzip command using gzip?

Ans) gzip command creates a zip file using given the filename in the same directory.

gzip command

gunzip command unzip the file.

gunzip command

Q #23) Explain the method of changing file access permission?

Ans) There are three sections to consider when creating/changing file access permission.

  • File owner’s user ID
  • File owner’s group ID
  • File access mode to define

These three parts arrange as follows.

(User permission) – (Group permission) – (other permission)

Three types of permission can define.

  • r – Reading permission
  • w – Writing permission
  • x – Execution permission

Q #24) How to display the last line of a file?

Ans) This can perform using either “tail” or “sed” commands. The easiest way is to use “tail” command.

tail command

In the above example code, the last line of the README.txt is displayed.

Q #25) What are the various IDs in UNIX processes?

Ans) Process ID is a unique integer that UNIX uses to identify each process. The process executes to initiate other processes is called parent process and its ID is defined as PPID (Parent Process ID).

getppid() – Is to retrieve PPID

Every process is associated with a specific user and is called the owner of the process. The owner has all the privileges over the process. The owner is also the user who executes the process.

Identification for a user is User ID. The process also associated with Effective User ID which determines the access privileges to accessing resources like files.

  • getpid() – Retrieve process id
  • getuid() – Retrieve  user id
  • geteuid() – Retrieve effective user id

Q #26) How to Kill a process in UNIX?

Ans) The Kill command accepts process ID (PID) as an in a parameter. This is applicable only for the processes own by the command executor.

Syntax – kill PID

Q #27) Explain the advantage of executing processes in the background?

Ans) The general advantage is to execute processes in the background is to get the possibility to execute some other process without waiting for the previous process to get completed. The symbol “&” at the end of the process tells to the shell to execute given a command in the background.


Q #28) What is the command to find maximum memory taking process on the server?

The command top displays the CPU usage, process id, and other details.

Command 

Command

Output 

Output

Q #29) What is the command to find hidden files in the current directory?

And) ‘ls –lrta’ is to display hidden files in current directory.

Command 

lrta

Output 

lrta Output

Q #30) What is the command to find the currently running process in Unix Server?

Ans) “ps –ef” command is used to find current running process. Also “grep” with a pipe can use to find specific process.

Command 

ps –ef

Output 

ps –ef Output

Q #31) What is the command to find remaining disk space in UNIX server?

Ans) The command “df -kl” use to get a detail description on disk space usage.

Command –

df -kl

Output –

df -kl Output

Q #32) What is the UNIX command to make a new directory?

Ans) “mkdir directory_name” is used to create a new directory.

Command – 

mkdir directory_name

Output –

mkdir directory_name Output

Q #33) What is the UNIX command to confirm a remote host is alive or not?

Ans) Either “ping” or “telnet” command can use to confirm a remote host alive or not.

Q #34) What is the method to see command line history?

Ans) The “history” command display all the command used previously within the session.

Command –

history

Output –

history Output

Q #35) Discuss the difference between swapping and paging?

Ans) Swapping – Complete process is moved to main memory for execution. To provide the memory requirement, process size must be less than the available main memory capacity. The implementation is easy but is an overhead to the system. Memory handling is not more flexible with swapping systems.

Paging – Only the required memory pages are moved to the main memory for execution. The size of the process does not a matter of execution and it no needs to be less than available memory size. Allow a number of processes to load to main memory simultaneously.

Q #36) What is the command to find weather system is 32 bit or 64 bit?

Ans) “arch” or “uname -a” can use for this process.

Command and outcome 

(Note: Click on the image for enlarged view)

Command and outcome

Q #37) Explain ‘nohup’ in UNIX?

Ans) “nohup” is a special command that is available to run a process in the background. The process started with ‘nohup’ command is not terminating even the user started to log off from the system.

Q #38) What is the UNIX command to find how many days the server is up?

Ans) “uptime” command returns the number of dates that the server is up.

uptime

Q #39) What is the mode that fault handler executes?

Ans) At the Kernel mode.

Q #40) What is the purpose of “echo” command?

Ans) “echo” command is similar to “ls” command and it displays all the files in current directory.

Q #41) What is the explanation for protection fault?

Ans) When the process access a page, which do not have access permission is refers as protection fault. Also when a process attempt to write on a page whose copy on write bit was set during the fork() system call is incurred for protection fault.

Q #42) What is the method to edit a large file without opening it in UNIX?

Ans) The “sed” command is available for this process ‘.sed’ stands for a team editor.

Example –

sed

Above code will replace from the README.txt file.

aaa of README

Q #43) Describe the concept “Region”?

Ans) Continuous area of processes address space (text, data, and stack) is identifying as a region. Regions are shareable among the processes.

Q #44) What is mean by user area (u-area, u-block)?

Ans) The area is only manipulated by the kernel and it contains the private data. This is unique to the process and each process allocated to u-area.

Q #45) What is called piping?

Ans) “piping” is used to combine two or more commands together. The output of the first command work as the input of the second command, and so on. Pipe character ( | ) is represent piping.

Q #46) What is the process to count the number of characters and line in a file?

Ans) “wc – c filename” command can use to retrieve the number of characters in a file and “wc –l filename” command can use to retrieve the number of lines in a file.

wc – c filename

Above command returns the number of characters in README.txt file.

number of characters

Above command returns the number of characters in README.txt file.

Conclusion

The article is based on most frequently asked UNIX command, admin basic interview questions with detailed answers. The theoretical and practical knowledge of the candidate will measure with the answers he provides for each question.

Detailed answers also available for each question and it will help if somebody needs to improve his/her knowledge on UNIX. Most of the commands come with the expected output.