Unix Interview Questions
An Overview of Unix
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 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.
Advantages of Unix
- Each big task can be split into simple commands and utilities
- Can be used on a variety of machines
- Can run many programs with less physical memory consumption
- Multiple users can perform various tasks at the same time without interfering with each other’s work. Each user’s work is protected.
- Cleanly defined permissions and access for each user for each file.
In our list of Unix interview questions, we have covered all the essential aspects of Unix. Read on to know more.
Unix was developed at AT&T Bell Labs by Ken Thompson and Dennis Ritchie in 1979. The first portable version of Unix was V7. Check out our Unix interview questions list to understand how Unix processes command written by the user.
The latest version of Unix is 4.20.8 released on 12 February 2019.
Best Unix Interview Questions And Answers
- What are the file permissions and access modes in Unix?
- 17. What are the common directory management commands in Unix?
- What is Unix and why is it important?
- What is a filter in Unix? Give an example.
- What is the role of the kernel in Unix?
- How to install Unix on Windows 10?
- How is Unix different from Linux?
- What are the essential features of the Unix operating system?
- What are different types of files in UNIX?
- How to compare two text files in UNIX?
- What is the command to compare two files in UNIX?
- How to find out what processes are running in the background in Unix?
- How do you kill a process in Unix?
- What are a shell in Unix and its types?
- What is the difference between an absolute path and a relative path in Unix?
- What are system variables in Unix?
- What are pipes and filters in Unix?
- How to find the path in Unix?
- What command is used to switching between users in Unix?
- How to check logs in Unix?
- What is Hardlink and Softlink in Unix?
- What is Unix orphan process?
- How zip the file in Unix?
- How to stop an infinite loop in Unix?
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 –
- Characters 2-4 (rwx) – means the owner has read, write and execute permission,
- Characters 5-7 (r-x) – indicates that the group has read and executed permission,
- Characters 8-10 (r--) – indicates that everyone else has only read permissions.
- cd – change directory
- pwd – current directory
- mkdir – create a new directory
- rmdir – remove an empty directory
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.
Unix is important:-
- Firstly, because of its design attributes from the initial release itself. That is, each complex task is divided into small, modular utilities that are easy to do.
- Secondly, during the initial internet boom, most web servers were UNIX machines from IBM, Sun, etc., hence making it a standard system for web servers.
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.
- Download VirtualBox (https://www.virtualbox.org/wiki/Downloads) and create a virtual machine. Select memory and virtual hard disk requirements.
- Download the ISO image file from a reliable source.
- Install the distribution in the VirtualBox in seamless mode.
Alternatively, you can install Unix in dual boot.
Linux can be said as a clone of Unix with the following differences –
|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…|
- It is a multi-user, multitasking system
- Uses kernel and shell to execute commands and complete tasks
- Hierarchical file system
- Easily portable to other machines as the code can be easily changed and compiled.
- Has pipes and filters to divide complex tasks into smaller utilities and then combine them.
- Application code is independent of the hardware vendor.
Continue reading our Unix interview questions list to know more about each of these features.
The different types of UNIX files are –
- ordinary files – text, data or program instructions.
- directories – stores regular and special files.
- special files – device files, used for input and output operations.
- pipes – temporary file that holds intermittent data until the second last command.
- sockets – allows advanced communication between several processes.
- symbolic links (soft links) – contains the path to another file (reference file)
You can use the following commands to compare two files –
- cmp [options] file1 file2 – compare 2 files character by character
- comm [options] file1 file2 – compare sorted files
- diff [options] file1 file2 – compare two files line by line
Type the command jobs to see the processes running in the background.
Example – $ jobs give the output as –
+ 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’.|
- Pipes – a pipe connects small commands together to execute a complete complex task. Pipe symbol is ‘|.’ The flow of data through the pipe is from left to right. Example – $ cat names.txt | grep “Sam” | tee sam.txt | wc -1
- Filter – Filters are used to modify the output of a command. Examples of filters are grep, sort, more, less, cat, cut and so on.
Use the ‘su’ command to switch between users in Unix.
Syntax – su [options] [username]