Here we have provided the most commonly asked UNIX interview questions and answers. All of these questions are asked during the Java developer, UNIX administrator, or other support role interview.
What is Unix?
Unix is one of the most popular operating systems, and it is widely used as an operating system for servers. Nonetheless, Unix can also be used as an OS for desktops and laptops. Originally, Unix was designed specially as a convenient platform for programmers so they could easily run the software. Over time, this OS grew, and users started adding their tools to the system and sharing it with other developers.
Do you wish to learn Unix from scratch and master it? Here you can get started with the course .
Top UNIX Interview Questions and Answers
We have categorized the commonly asked Unix interview questions into three levels, namely Basic, Intermediate, and Advanced.
Basic Unix Interview Questions
1. 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 desktops and laptops work on single-user systems because they come at a low cost and multiple applications run on them.
2. List some features of Unix.
- Highly portable
- Unix shell
- High productivity development tools
- Greater number of utilities
3. What are the filters in UNIX?
Answer: Filters are the programs or subroutines in the UNIX operating system that can accept input from the standard input device, perform the corresponding operation and show the result to the user. The terminal is one of the most important filters of the UNIX operating system.
4. Describe the UNIX file system.
Answer: In UNIX, the data resides in the files, and files reside in the directories, and all the directories are organized in a tree-like structure that is known as the file system of the Unix. Unix follows the multi-level hierarchical structure to organize all of its directories, and this organization of directories is known as a directory tree. The top directory of the UNIX directory tree is called the root directory, which is represented by /.
5. What is the command to list out the hidden files in Unix?
Answer: The ls-lrta command can list all the hidden files of the current working directory.
6. What are the various files contained by the UNIX file system?
Answer: Unix file system contains mainly six types of files:
- Ordinary Files : These files contain data, text, program code, and so on.
- Directories : A directory stores files and subdirectories. UNIX directories are equivalent to the Windows folders and drives.
- Special Files: These represent physical devices such as drivers, terminals, and I/O operations.
- Pipes: It helps to link two or more commands together.
- Sockets: These are the special files that help to perform the inter-process communication.
- Symbolic Links: These links are used to address other files present in the file system.
7. Name the command that displays the current date of the system.
Answer: To print the current date, we can use the date command.
8. How can we zip and unzip a file in Unix?
Answer: To zip a file, we can use the gzip command and to unzip a zipped file, we can use the gunzip command.
9. What is the difference between cat and more commands?
Answer: Both the commands display the contents of a file. The cat command displays 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, the more command displays or prints only that much content of the file that will fit on your computer screen, and if you want to see the extra content that is left, you just need to press Enter, and the content will be shown in the next line.
$ cat filename $ more filename
10. Who is the superuser in UNIX?
Answer: The user who is logged in with the root account is known as the superuser, and the superuser has access to all the root directories and commands.
11. Why do we require a superuser, and what is another way to become the superuser apart from root login?
Answer: For the administrative tasks and their associative commands, we require a superuser. Apart from the login root directory, the child user can become a superuser by using the su command and the corresponding superuser password.
12. What is the difference between multiuser and multitask?
Answer: Multiuser means more than one user can operate the same operating system simultaneously. Multi-task, however, means a single user can operate more than one program at a given time.
13. What are the major parts of the Unix operating system?
Answer: The UNIX operating system is made up of 3 major parts:
14. What is the shell?
Answer: The shell is a program or command-line interpreter that provides an interface between the user and the operating system. The main task of the shell is to accept the user commands and execute them.
15. What does the tree command do?
Answer: It lists all the directories and files present in the file system in a tree-like structure.
16. Name some major tasks performed by the shell.
- It can execute the program.
- The shell provides an interface for input and output.
- It provides us with commands that 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.
17. Write the standard syntax for the UNIX shell commands.
Answer: Command (-argument) (-argument) (-argument) (filename)
18. What is the UNIX shell command that can remove all the files and subdirectories that 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 deletes the directories with files.
- * - This command means include all.
19. 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 terms, a directory can be defined as a folder that can hold various files and sub-folders, and UNIX follows the hierarchical directory structure.
20. 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.
21. What is a relative path?
Answer: The relative path is the path related to our current working directory. In the relative path, we can move from our current directory to the destination directory.
22. Name some most common shells with their indicators.
|Bourne Again shell||Bash|
|Enhanced C shell||tcsh|
23. What is the command to display all the files and directories present in the current directory in alphabetical order?
Answer: With the help of the ls -l command, we can list down all the files and folders in alphabetical order.
Intermediate Unix Interview Questions
24. What is a kernel?
Answer: The kernel is the core of the operating system that handles most of the work. The main task of the kernel is to allocate time and memory to the programs, handle the file storage and communicate between system calls.
25. What is the 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) shells, along with a scripting language similar to the Bourne shell.
26. Give some major features of the Korn shell.
- Built-in-editor that can simulate emacs or vi.
- Gives support for integer arithmetic.
- Supports arrays.
- Supports string manipulation.
27. What is command substitution?
Answer: Command substitution allows the user to use the output of one command as an argument to another command. To use the command substitution, we use the dollar sign ($) followed by a pair of single parenthesis; $() . The command output we want to use goes inside the parenthesis.
28. What is a link in UNIX, and why did we create it?
Answer: In Unix, we define a link as a pointer to a file. Thus, a link can point to any file or directory present in the system memory. We create a link as a shortcut to access files. The concept of Unix links is similar to Windows shortcuts.
29. How many types of links can we create in UNIX, and what is the difference between them?
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 soft link:
$ ln -s [original filename] [link name]
If we create a hard link to a file, then even if the file gets deleted or moved to another location, we can still access the file using the hard link. On the other hand, if we create a soft link of a file, then if it is removed or moved, then we can not access the file using the soft link.
30. 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 pointed out by the Inode of a file:
- Size of the file.
- Device ID.
- User ID of the file.
- Group ID of the file.
- The file mode information and access privileges for the owner, group, and others.
- File protection flags.
- The timestamps for file creation, modifications, and so on.
- Link counter to determine the number of hard links.
- Pointers to the blocks storing the file’s contents.
31. What is the fork() system call?
Answer: The fork() is a command that can create an exact duplicate child process from the parent process with a different PID (process identifier) number. When we execute both the processes, and we get 0 as a return value, then that means the child process will execute. However, if we get any other value, then that means that the parent process will execute.
Advance Unix interview Questions
32. Why is it that it is not advisable to use root as the default login?
Answer: The root directory contains the important libraries and system configuration, and if by mistake the user deletes or modifies some important library or configuration scripts, then it could be difficult for the user to revert the mistake.
33. You have a file (p.txt) inside a directory (Dictionary). If you made some changes in the content of the file, then what would be the changes occurring 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, Inode will show some variation. Thus, the Inode file, the file size, the time of last access, and the time of last modification will be updated.
34. What is the difference between cmp and diff commands?
Answer: The cmp command is used to check the differences between the data of two files, but it returns only the first difference. On the contrary, the diff command shows all the differences between the files. syntax :
$ cmp file1 file2 $ diff file1 file2
35. 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 the | operator.
36. How to see the information related to the running processes in UNIX?
Answer: In UNIX, we have the ps command, which can report the information related to the running processes.
37. What are process groups?
Answer: When there is a collection of one or more than one process, then it would be considered as a process group. All the processes in the group may or may not be of the same job, but often 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.
38. What are the chmod, chown, and chgrp commands?
|chmod||It can change the permission set of the file.|
|chown||Changes the ownership of the file.|
|chgrp||Changes the group of the file.|
39. How to show the last line of a file?
Answer: To print or show the last line of a file, we can either use the tail or sed command.
40. What are the various commands associated with the process ids?
- getpid() = Shows the process id.
- getppid = Displays the parent process id.
- getuid() = Shows the user id.
- geteuid = Shows the effective user id.
41. What is the command to destroy the process explicitly?
Answer: To destroy a process, we use the kill command along with the process id. For example: kill PID
42. How can we terminate a command?
Answer: By default, if we write a command and press enter, then the command gets terminated and interpreted by the operating system. However, we can also use an ampersand (&) or semicolon after the command to terminate it.
43. 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 as equivalent to regular expressions. There are three major types of wildcards:
- Star Wildcard (*)
- Question Mark Wildcard(?)
- Square Brackets Wildcards()
44. What symbol do we use to tell the shell interpreter to run the process in the background?
Answer: We can add the ampersand ( & ) symbol at the end of a command to tell the shell to execute the respective command in the background.
45. What is the major advantage of running a process in the background?
Answer: The major advantage of running a process in the background is that we do not have to wait for the previous process to end in order to start our new process.
46. What is the key difference between swapping and paging?
Answer: 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.
47. Write the command that will find all the files present in the directories except those that have the word “tech” in them.
grep –vi tech *.txt
48. Write the command to shut down the system in 30 minutes.
shutdown –r +30
49. Write the command that will show the remaining disk space present in the UNIX server.
50. Write a shell script that asks a user to enter her 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 a web developer or any other developer interview that is related to the server, go through these Unix interview questions first.
Most of the questions that we have provided here are associated with the common OS terminology because mostly all the operating systems, such as Unix, Linux, macOS, and Windows, share many similar concepts.
To explore more interview questions on Unix, you can consider buying the course here .
People are also reading: