Unix is one of the most popular operating systems, and it is widely used as a Server Operating System. Apart from the server, Unix can also be used as a general Operating system for desktops and laptops. Initially, Unix was specially designed as a convenient platform for the programmers so they can easily run their software. Still, with time this OS grew, and users started adding their tools to the system and shared it with other developers.
Top UNIX Interview Questions and Answers
Here we have provided the most commonly asked UNIX interview questions and answers. All of these questions asked during the Java developer, UNIX administrator, or other support role interview.
Question: What is a Single-user system?
Answer: When an Operating system is dedicated to a specific person, and only that person can operate and work on that operating system then that system is considered as a Single-user operating system. These days mostly all desktop and laptops work on Single-user systems because they come with low-cost and multiple applications run on it.
Question: List some features of Unix.
- Highly portable
- Unix Shell
- Machine Independent
- High Development tools
- Greater number of Utilities
Question: What are the filters in UNIX?
Answer: Filters are the program or subroutines in the UNIX operating system which can accept input from the standard input device, perform the corresponding operation and show the result to the user. Command terminal is one of the most important filter of the UNIX operating system.
Question: Describe the UNIX file system.
Answer: In UNIX the data reside in the files and files reside in the directories, and all the directories are organized in a tree-like structure which is known as the file system of the UNIX.
The UNIX follows the multi-level hierarchical structure to organize its all directories and this organization of directories known as a directory tree. The top directory of UNIX directory tree is called the root directory which represents by /.
Answer: ls-lrta command can list all the hidden files of the current working directory.
Question:What are the various files contained by the UNIX file system?
Answer: Unix file system contains mainly 5 types of Files:
- Ordinary Files: These files contain data, text, program code, etc.
- Directories: Directory stores files and subdirectories, UNIX directories are equivalent to the Windows folders and drives.
- Special Files: Represent physical devices such as drivers, terminal, I/O operations, etc.
- Pipes: It helps to link to command together.
- Sockets: These are the special files which help to perform the inter-process communications
- Symbolic Links: These links are used to address other files present in the file system
Question: Name the command which displays the current date of the system.
Answer: To print the current date, we can use the UNIX date command.
Question: How can we zip and unzip a file?
Answer: To zip a file we can use the gzip command and to unzip a zipped file we can use the gunzip command.
Question: What is the difference between cat and more command?
Answer: Both the commands are used to display the content of the file, however, the cat command display all the content on your screen and if the content does not fit on your display screen then you can watch it by scrolling down, on the other hand, more command display or print only that much content of the file which will fit on your computer screen and if you want to see the extra content which left off, you just need to press enter and the content will be shown in the next line.
$ cat filename $ more filename
Question: Who is superuser in UNIX?
Answer: The user who is log in with the root account is known as the superuser of the operating system, superuser has all access to the root directories and commands.
Question: Why do we require a superuser and what is another way to become the superuser apart from root login?
Answer: For the administrative task and its associative commands, we require superuser. Apart from the login root directory, the child user can become a superuser by using the su command and the corresponding superuser password.
Question: What is the difference between multiuser and multitask?
Answer: Multiuser means more than one user can operate the same operating system simultaneously.
Multi-task means a single user can operate more than one program at a given time.
Question: What are the major parts of the Unix operating system?
Answer: The UNIX operating system is made up of 3 major parts:
Question: What is Shell?
Answer: The shell is a program or command line interpreter that provide a user interactive interface between the user and the operating system, the main task of the Shell to accept the user commands and execute them.
Question: What does tree command do?
Answer: It lists all the directories and files present in the file system in a tree-like structure.
Question: Name some major tasks performed by the shell.
- It can execute the program
- Provide an interface for input and output.
- Shell provides us with commands which help us to customize our environment.
- The shell has its own programming langue which is interpreted by nature.
- Like other programming languages, the shell’s programming language gives support for variable assigning.
Question: Write the standard syntax for the UNIX shell commands.
Answer: Command (-argument) (-argument) (-argument) (filename)
Question: What is the UNIX shell command that can remove all the files and subdirectories which are in the current directory?
Answer: For the simultaneous removal or deletion of files and subdirectories, we use the rm -r* command.
- rm – This command is used to delete files.
- -r – This command is used to delete the directories with files.
- * – This command means include all.
Question: What is a directory in UNIX?
Answer: A directory can be defined as a location where we can store our files including sub-directories. In simple term, a directory can be defined as a folder which can hold various files and sub-folders, and UNIX follows the hierarchical directory structure.
Question: What is an absolute path?
Answer: If we define a specific path location of the file from the root directory to the file directory then that path is known as an absolute path. In the absolute path, we always have to move from the root directory to the destination file.
Question: What is a Relative path?
Answer: The relative path defined as the path related to our current working directory. In the relative path, we can move from our current directory to the destination directory.
Question: Name some most common shells with their indicators.
|Bourne Again shell||Bash|
|Enhanced C shell||tcsh|
Question: What is the that show all the files and directories present in the current directory in alphabetical order?
Answer: With the help of ls -l command, we can list down all the files and folders in alphabetical order.
Question: What is a Kernel?
Answer: The kernel is the core of the operating system which handle most of the work. The main task of the kernel to allocate time and memory to the programs, handle the file storage and communicate between system call.
Question: What is Korn Shell?
Answer: It is a UNIX shell that builds on some of the most popular Unix shells. It contains the features of C (csh) and Tab C(tcsh) shell, along with a scripting language similar to Bourne shell.
Question: Give some major features of the Korn shell.
- Built-in-editor which can simulate emacs or vi
- Give support for Integer arithmetic
- Support arrays
- Support String manipulation.
Question: What is Command substitution?
Answer: Command substitution, allow the user to use the output of one command as an argument to another command. To use the command substitute we use the dollar sign ($) followed by a pair of single parenthesis $(). The command output we want to use go inside the parenthesis.
Answer: In UNIX we defined link as a pointer to a file, a link can point to any file or directory present in the System memory. We create a link as a shortcut to access files. UNIX links concepts are similar to the Windows Shortcuts on the desktop or in any other folder.
In UNIX we can create two types of Links.
- Hard Link
- Soft link
Syntax to create a hard link
$ ln [original filename] [link name]
Syntax to create a hard link
$ ln -s [original filename] [link name]
If we created a hard link to a file then even the file gets deleted or moved to another location still we could access the file using the hard link, on the other hand, if we created a soft link of a file then remove or move the file location then we could not access the file using that soft link.
Question: What is Inode?
Answer: An Inode is a special number assigned to a file when it is created, and this number holds all the key information about that file. Here is the list of all the information point out by the Inode of a file.
- Size of file
- Device ID
- User ID of the file
- Group ID of the file
- The file mode information and access privileges for owner, group and others
- File protection flags
- The timestamps for file creation, modification etc
- link counter to determine the number of hard links
- Pointers to the blocks storing file’s contents
Question: What is the fork() system call?
Answer: The fork() is a command which can create an exact duplicate child process from the parent process with different PID(process identifier) number. When we execute both the processes if we get 0 as a return value that means child process gets executed, apart from 0 if we get any other value that means the parent process gets executed.
Question: Why is it that it is not advisable to use root as the default login?
Answer: The root contains the important libraries and system configuration, and if by mistake the user deletes or modify some important library or configuration scripts by mistake then it could be difficult for the user to revert the mistake.
Question: You have a file(p.txt) inside a directory (Dictionary), if you made some changes in the content of file p.txt then what would be the changes occur in the directory, Inode and file?
Answer: By modifying the content of the file there would be no changes in the Directory and the file name, however, the Inode will show some variation, the Inode file, the file size, time of last access, and time of last modification will be updated.
Question: What is the difference between cmp and diff command?
Answer: cmp command is used to check the differences between the data of two files, but it returns only the first difference.
diff command is used to show all the differences between the files.
$ cmp file1 file2 $ diff file1 file2
Question: What is piping?
Answer: Piping is a way to redirect the standard output of one command to another command for further processing, and it is represented by | operator.
Answer: In UNIX we have a command ps which can report the information related to the running processes.
Question: What is process groups?
Answer: When there is a collection of one or more than one processes then it would be considered as a process group. All the processed in the group may or may not be of the same job, but often it seems that process groups hold the processes of the same job.
Each group process has a unique process ID and to get that ID we can use the getpgrp() command.
Question: What chmod, chown and chgrp commands do?
|chmod||It can change the permission set of the file|
|chown||Change the ownership of the file|
|chgrp||Change the group of the file|
Question: How to show the last list of a file?
Answer: To print or show the last line we can either use the tail or sed command.
Question: What are the various commands associated with the process ids?
- getpid() = show the process id
- getppid = show the parent process id
- getuid() = show the user id
- geteuid = show the effective user id.
Question: What is the command which can destroy the process explicitly?
Answer: To kill a process, we use the kill command along with the process id.
Question: How can we terminate a command?
Answer: By default, if we write a command and press enter then the command get terminated and interpreted by the Operating system, however, we can also use an ampersand (&) or semicolon after the command to terminate it.
Question: What is a wildcard?
Answer: A wildcard is a character that acts as a substitution for other characters that are supposed to be searched by the matching pattern, the concept of wildcard can be seen equivalent to the regular expression in Computer science.
There are three major types of wildcards:
- Star Wildcard (*)
- Question Mark Wildcard(?)
- Square Brackets Wildcards()
Question: What symbol do we use to tell the shell interpreter to run the process at the background?
Answer: We can add the symbol ampersand (&) at the end of a command to tell the shell to execute the respective command in the background.
Question: What is the major advantage of running a process in the background?
Answer: The major advantage of running a process in the background, we do not have to wait for the previous process to end in order to start our new process.
Question: What is the key difference between swapping and paging?
Answer: The swapping is a technique of swapping the complete process from the secondary memory to the main memory back and forth, whereas paging only deals with the memory allocation of the process in the main memory.
Question: Write the command which will find all the files present in the directories except those which has the word “tech” in them.
grep –vi tech *.txt
Question: Write the command which will shut down the system in 30 minutes.
shutdown –r +30
Question: Write the command which will show the remaining disk space present in the UNIX server.
Question: Write a shell script which asks user to enter his name and display it.
echo Hello! Enter your name\? read name echo $name
Here we have provided the top 50 UNIX interview questions along with their answers. Before you go for the web-developer or any other developer interview, which is related to the server, go through these questions first. Most of the questions which we have provided here are associated with the common OS terminology because mostly all the operating system such as UNIX, LINUX, MAC, and Windows shear some similar concepts.
You may be also interested in:
- Linux vs Windows: Head to Head Comparison
- How to Install Kali Linux?
- Types of Operating System
- How to Install Python PIP on Windows, Mac and Linux?
- How to Install Python 3 on Windows 10
- Best Unix Interview Questions
- CSS Interview Questions
- PHP Interview Questions
- Python Interview Questions
- C Interview Questions