Unix is a stable and secure operating system that is capable of handling commands from multiple users at the same time. The innermost level of the Unix environment, Kernel coordinates the computer internals and allocates all the resources. Users can communicate with the kernel through a program known as a shell, which translates commands written by the user into a language that the kernel can interpret. Want to clear interviews in one shot? Read our Unix interview questions.
Here in this article, we will be listing frequently asked Unix Interview Questions and Answers with the belief that they will be helpful for you to gain higher marks. Also, to let you know that this article has been written under the guidance of industry professionals and covered all the current competencies.
Unix is an operating system that supports multitasking and multi-user capabilities. Unix provides a simple and user-friendly interface for users. It is the first OS to be written in high-level (C) programming language.
The filter is a program that gets its data from the input stream and prints the results to the output stream. Examples – grep, sort, tail, head, cut, etc.…
The kernel is the central control of Unix. Kernel is the first part to be loaded when the OS loads and remains throughout the session. It executes processes, manages memory and handles interrupts and system calls. It provides drivers for controlling the hardware.
Unix can be installed on Windows 10 using VirtualBox, an open source virtualization tool.
Alternatively, you can install Unix in dual boot.
Linux can be said as a clone of Unix with the following differences –
S.no | UNIX | LINUX |
---|---|---|
1. | UNIX does not have a free version. | Linux is open source and freely distributed. |
2. | Requires more wait time for an issue to be fixed properly | Community-based; hence solutions are faster. |
3. | It is mainly used for web servers, PCs and workstations. | Can be installed on any device, tablet, mobile, PC, etc. |
4. | Source code is not available | Open source, code is available for everyone. |
5. | Different versions are AIS, BSD etc… | Different versions are Redhat, Solaris, Ubuntu etc… |
Continue reading our Unix interview questions list to know more about each of these features.
Type the command jobs to see the processes running in the background.
Example – $ jobs give the output as –
[134]+ Running sleep 50 &
where 134 is the job number.
Use the command kill along with the process id (PID) to kill a process.
Example – kill 12323
If this does not destroy the process, add the signal number for a kill to kill the process. Unix cannot ignore the signal number.
Example – kill -9 12323
Continue reading Unix interview questions to know how you can stop an infinite loop using the same command
Shell is a program that gives us an interface between the Unix OS kernel and user. By this interfacing, the user can execute utilities and applications using the shell. Each user gets a unique shell when he logs in or opens a console. The different shells are Bourne shell (sh), C shell (csh), the Korn shell (ksh), GNU Bourne-Again Shell (bash).
S.no | ABSOLUTE PATH | RELATIVE PATH |
---|---|---|
1. | the full path starting at the root directory (/). | Path in relation to the present working directory as the reference. |
2. | Example - /home/math/tutorial | Access the current directory using the command ‘pwd’. Change the directory using ‘cd’. |
Some system variables set in Unix by default are HOME, USER, HOST, DISPLAY, and PATH. These can be environment variables or local variables enabled by the shell.
To find the path, use the command – echo $PATH
Use the ‘su’ command to switch between users in Unix.
Syntax – su [options] [username]
You can check logs in the file syslog located in /etc/syslog.conf
S.no | HARDLINK | SOFTLINK |
---|---|---|
1. | Additional name for the same existing file. Hardlink acts as a shortcut to the file that has been hardlinked. | A file that points to another file through a pointer. There is no data in the target file. |
2. | Preserves the contents of a file. | If the target file is deleted, softlink is rendered useless. |
A process, whose parent process terminates, finishes or crashes and doesn’t exist anymore is called orphan process. They are adopted by the init system process.
You can use the zip command to zip files in Unix.
Example – zip math.zip file1 file2 file3
To stop an infinite loop, kill the process using the ‘kill PID’ command.
Example – $ kill -9 24566
There are three types of permissions – owner, group and other (public), all of which can be listed using the command ls -l. Each user can have one or more of the following access – read (r), write (w), execute (x). Example, -rwxr-xr-- represent the file permissions for owner, members and everyone else as –