Intermediate Unix Interview Questions
We have discussed the easy-level Unix Interview Questions. Now it’s time to increase the difficulty level of our Unix Interview Questions gradually. So, let’s discuss some of the medium-level questions.
25. What types of files are available under UNIX?
Ans: Various file types under UNIX include:
- Regular/Normal files
- File directories
- Special character files
- FIFO
- Block special files
- Sockets
- The Symbolic Links
26. List some of the most popular network commands in UNIX.
Ans: Some of the popular network commands in UNIX are:
- PING: An echo request for connectivity checking.
- TELNET: Used for the remote login system.
- FTP: File Transfer Protocols used to transfer files between systems.
- SU: Command used for User Switching.
- FINGER: Command for acquiring information
- NSLOOKUP: It performs the DNS query.
- HOSTNAME: This provides the IP Address and the domain name.
27. Distinguish between the cmp and diff commands.
Ans: The cmp command is primarily used to compare two files byte per byte, after which the first mismatch is displayed.
On the other hand, the diff command is used to show the modifications that must be made to make the two files identical.
28. In UNIX, how do you choose and set the path?
Ans: A variable called PATH or path determines where the shell will look for a command each time you input one. When an error message is returned, it could be because the command was not on your path or because it didn't exist in the first place. The command "set path = [directory path]" can be used to set the path manually.
29. Is it possible to view details about a process as it is running?
Ans: A process identifier is used to identify each process specifically. The ps command can display information about a process, including its details and status.
30. What do the following commands—chmod, chown, and chgrp—do?
Ans: The following tasks can be performed:
- We can change the file's permissions by using the chmod command.
- We can change the file's ownership with the chown command.
- We can change the file's group with the chgrp command.
31. Describe a UNIX link.
Ans: To give a file more than one name, utilise a link. It functions similarly to a pointer to a file; a file may have many pointers. Two different kinds of links exist.
Hard link: These hard-linked files reference the exact physical location of the file since they share the same inode value as the original. The link will continue to function even if the file is moved to a different directory.
The Syntax is:
ln [Original_Filename] [Link_Name]
Symbolic Link: A symbolic link has a different inode from the original one and is similar to the file shortcut feature. The link may not function if the original file is moved, but it can still refer to other files.
The Syntax is:
ln -s [Original_Filename] [Link_Name]
32. How do you distinguish between grep and egrep in shell scripting?
Ans: This is one of the most frequently asked questions in the Unix Interview Questions and Answers. Let’s understand the solution to this problem.
egrep is an advanced version of grep. egrep can search using extended regular expressions in addition to regular expressions.
The following command will determine if any files have the .env|.json extension.
$ ls | grep '.env|.json.'
However, in this instance, since the character "|" will be regarded as a metacharacter, it checks to see whether any files have the ".env" or ".json" extensions.
$ ls | egrep '.env|.json'
33. Distinguish between paging and swapping?
Ans: Swapping: In the case of swapping, the entire process is loaded into the main memory; as a result, only the processes that are less than the primary memory size can be executed. Although relatively simple to do, this is ineffective.
Paging, on the other hand, loads only the necessary memory pages into the main memory instead of loading the entire process. Although challenging to implement, this enables us to run several tasks simultaneously.
34. What is a daemon, exactly?
Ans: A daemon is a background task or process in charge of one or more specific duties. The Unix OS relies on this core idea. The multiple system daemons that make up the Unix kernel handle memory management, file system management, printer jobs, network connections, and several other functions.
35. What is your knowledge of the MBR?
Ans: Its full name is Master Boot Record, a little software that runs when a computer boots up to locate the operating system and load it into memory. The BIOS (basic input-output system) searches for the MBR during the initial stages of system boot-up, loads it into memory, and then the MBR takes control.
36. Explain the Superblock in UNIX.
Ans: A SuperBlock is a program that keeps records of particular file systems, including the block size, the number of empty and filled blocks and their corresponding counts, the size of block groups, and the location of the inode tables on the disc, and use data.
Superblocks generally fall into one of two categories:
Default Superblock: The default superblock has a fixed offset from the first disc partition of the system.
Redundant Superblock: Redundant superblocks are replicas of the default superblock used in case the default superblock is damaged by a system crash or other faults.
37. How does UNIX kill a process?
Ans: The process ID (PID) is an argument that the kill command accepts. This only applies to processes that the command executor owns.
The Syntax for Killing the process is: kill PID.
38. What benefit does running processes in the background have?
Ans: The ability to run another process without waiting for the preceding one to finish is the public benefit of running processes in the background. The shell is instructed to run a command in the background by the symbol "&" at the end of the process.
39. Explain some file manipulation commands in UNIX.
Ans: The questions related to Commands are one of the most important topics of the Unix Interview Questions.
Some of the file manipulation commands are as follows:
- cat filename: Show the contents of the file.
- mv [old_name] [new_name]: Move or Rename the file. Here the old name and new name are provided.
- Cp source destination: To copy the source file to the destination file.
- rm filename: To delete/remove the files.
- ls -f: The information about the type of the file.
- ls -s [old_name] [new_name]: To create the symbolic to the old file.
40. What causes a protection fault, and why?
Ans: A protection fault occurs when a process accesses a page for which it does not have authorization. Additionally, a protection issue occurs when a process tries to write on a page whose copy on the write bit was set during the fork() system call.
41. What does the term "region" mean?
Ans: The text, data, and stack regions of a process's address space are identified as a region. The processes can share regions.
42. What is piping?
Ans: To merge two or more commands, use "piping." The first command's output serves as the second command's input, and so forth. The pipe symbol (|) is used to denote piping.
43. What does "command substitution" mean to you?
Ans: The questions related to Commands are one of the most important topics of the Unix Interview Questions.
The procedure used by the shell each time a command enclosed in a backquote is handled known as command substitution. This procedure displays it on the command line in place of the standard output.
The following actions can be carried out by command substitution:
- Call the subshell
- Bring about word splitting
- Delete any last new lines.
- The commands "redirection" and "cat" enable setting a variable to the file's content.
- Permits setting a variable to the loop's output.
44. What function does the superuser perform?
Ans: In the Unix operating system, there are primarily three types of accounts:
- Root account
- System accounts
- User Account
The term "Root account" for user accounts is essentially the same as "Superuser." This user has total power over all files and commands on the system or fully open access. This user can also be considered the system administrator and is, therefore, free to execute any command. By using the root password, it is secured.
Must Read: SAP ABAP Interview Questions
45. How would you differentiate system calls from library functions when it comes to Unix commands?
Ans: In Unix, system calls and library functions are two different mechanisms used for interacting with the operating system and executing tasks. System calls are functions provided by the UNIX kernel while library functions are abstractions on top of system calls provided by user written programming libraries and scripts.
46. What is meant by alias mechanism?
Ans: In Unix an alias is a user-defined name that represents a command or a series of commands.
Example:
alias print_working_directory='pwd'
Now, if you type print_working_directory in the terminal, it will execute the pwd command.
This is just an example, alias should be some short string which makes it easier to execute long commands.
47. Can you explain the functions of the "chmod," "chown," and "chgrp" commands?
Ans: The functions of the commands, "chmod," "chown," and "chgrp" are mentioned below:
- chmod: Used to change file permissions, specifying who can read, write, or execute a file. It allows you to control access to files and directories
- chown: Changes the owner of a file or directory, which is essential for managing file ownership and access control
- chgrp: Alters the group ownership of a file or directory, useful for managing file access permissions within a group
48. Could you provide an explanation on the process of modifying file access permissions?
Ans: In Unix, you can modify file access permissions using the “chmod” command. This command allows you to change the read, write, and execute permissions for the owner, group, and others on a file or directory. chmod command can be used in two modes:-
Symbolic Mode
You can use simple symbols to assign permissions to owner, group and other users.
Syntax:
chmod [who][operator][permissions] file(s)
For example, to add write permission for group and others on a file named file_1.txt, use the following command:
chmod g+w,o+w text_1.txt
Numeric Mode
You can permissions using numeric values. Each permission (read, write, execute) is assigned a value:
- Read: 4
- Write: 2
- Execute: 1
The sum of these values represents the permission value.
Syntax:
chmod [permissions] file(s)
For example, to set read and write permission for the owner, and read-only permission for the group and others on a file named text_1.txt, use the following command:
chmod 644 text_1.txt
Advanced Unix Interview Questions
It’s time to practice some problematic UNIX Interview Questions. Below is the list of some hard-level UNIX Interview Questions.
49. Describe the networking protocol and stack for UNIX System.
Ans: TCP/IP is the standard networking stack protocol for the UNIX kernel. TCP/IP functions in two ways:
- IP (Internet Protocol) handles packet transmission between user programs and the networking layer, whereas
- TCP (Transmission Control Protocol) is in charge of the virtual circuit layer that enables bidirectional data transmission.

50. Explain the Virtual Memory Concept.
Ans: A method or system for addressing more memory than is there is known as virtual memory. The model is made up of several memory pages, which are typically 4 KB apiece. There is a translation layer between virtual and physical memory addresses.
To get the best performance possible while translating and mapping addresses, this translation layer, a kernel component, is typically written in machine language (Assembly).
The kernel employs the address translation layer to translate the virtual memory address into a physical memory address each time a user accesses memory. More excellent addresses than are physically achievable are made possible via virtual addressing.
51. What functionality does the '-l' provide when you list a directory?
Ans: When listing a directory with the '-l' option (e.g., using the 'ls' command), it provides a detailed, long-format listing. This format includes additional information about each file, such as permissions, owner, group, file size, modification date, and filename. It is useful for obtaining comprehensive information about the files and directories in a listing.
52. What does the UNIX zombie process do? What is the Zombie process like?
Ans: Child processes that are complete before the parent process are zombie processes. The process structure and address space are thus deleted after completion and released to the system, but the item in the process table is left in place. The parent dials wait() to inquire about the status of the child's process. The kid is referred to as a "zombie" during the time between the child terminating and the parent invoking wait().
53. How do you determine the hostname from an IP address in your network?
Ans: The nslookup command is used to query internet domain name servers, and it may also be used to perform a reverse lookup and find the hostname from an IP address.
54. Describe how UNIX systems boot up.
Ans: When the system starts, it is the first thing. The main phases are five:
- Hardware: BIOS checks for the hardware connection during system boot up.
- Operating System Loader: The MBR, or Master Boot Record, is the first 512 bytes of the boot device and contains the OS loader.
- Kernel: It initialises numerous computer parts, the operating system, and every piece of software that performs a task; typically regarded as a driver root user.
- Space process (init and inittab): The space process (init and inittab) provides the administrator a simple way to create an environment for some usage by defining what should be executed when the /sbin/init program is prompted to enter a specific run-level.
- Boot scripts: There is a single startup script present in a particular directory for each managed service (such as mail, nfs server, cron, etc.).
55. What do the different UNIX process IDs stand for?
Ans: The Unix process is identified by three ids:
- PID stands for Process Id, a specific number between 0 and 3000.
- Parent process ID (PPID)
- Processes are grouped using the PGID or process group id.
The functions getppid(), getpid(), and getpgrp() return the Parent Process ID, the Process ID, and the Process Group ID, respectively. A real user ID (the UID), an effective user ID (the EUID), a real user group ID (the GID), and an effective user group ID are also present in the process (the EGID).
56. Describe the many pathname kinds that can be employed in UNIX.
Ans: Any operating system's file system has a hierarchy of directories, and "Path" is defined as the specific location of a file or directory so that it may be accessed.
In Unix, there are essentially just two types of paths. The following is a definition of these:
- Absolute pathnames: These define a complete path indicating the location of a file or directory starting from the root directory (/) of the existing file system.
Absolute pathnames address system configuration files that do not move. It defines a complete route indicating the starting point of the actual file system, i.e., the root directory (/), from which a file or directory can be found. Absolute pathnames address system configuration files that do not move.
- Relative Pathname specifies the route from the user's current working directory or current working directory (pwd). The term "relative pathname" denotes the current directory, the parent directory, and files that are difficult or difficult to access. It specifies the route from the user's current working directory, also known as the present working directory (pwd).
The term "relative pathname" denotes the current directory, the parent directory, and files that are difficult or cumbersome to access.
57. What do you know about the interpretation of wildcards?
Ans: Wildcard characters are a unique class of characters that can stand in for one or more other characters. Wildcard interpretation is used when these characters are present in a command line. In this instance, a sorted list of files is used in place of these characters when the pattern fits the input instruction.
Wildcard characters like the asterisk (*) and question mark (?) are frequently utilised to create a list of files to process.
58. What is your knowledge of the tee command's applications?
Ans: In general, pipelines and filters are used in conjunction with the "tee" command. Essentially, this command accomplishes two things:
- Obtain information from standard input and send it to standard output.
- A copy of the input data is forwarded to the selected file.
59. Describe the mount and unmount commands.
Ans: The mount and unmount commands are as follows:
- As its name implies, the mount command allows users to access a storage device or file system by mounting it on an existing directory.
- The unmount command safely detaches the mounted file system to unmount it. This command's other function is to tell the system to finish any pending read and write activities.
60. Can you explain the contrasting features and purposes of "ps -ef" and "ps -auxwww" in Unix command usage?
Ans: The “ps -ef” and “ps -auxwww” commands are both used for displaying information about the running processes in a UNIX operating system, but there are differences in their output format and behavior.
ps -ef command
The “ps -ef” command displays process information in a simplified format, where each process has some limited number of columns. These columns include, process ID, user ID, parent process ID, etc. This command may not display information related to daemons, kernel thread or background processes.
ps -auxwww command
The “ps -auxwww” command provides the process information in a more detailed format with more columns such as process arguments, memory usage, start time of the process, etc. It displays information about all the processes in the system along with kernel threads, background processes and running daemons, however this command is only supported by older UNIX operating systems such as Solaris.
Unix MCQ
1. Which of the following is the core part of the Unix operating system?
- a) Shell
- b) Kernel
- c) Application Programs
- d) Command Interface
Answer: b) Kernel
2. What command is used to list all files and directories in Unix?
- a) list
- b) ls
- c) dir
- d) show
Answer: b) ls
3. Which command is used to change the file permissions in Unix?
- a) chmod
- b) chperm
- c) changeperm
- d) permset
Answer: a) chmod
4. How can you display the current directory in Unix?
- a) pwd
- b) cd
- c) displaydir
- d) showdir
Answer: a) pwd
5. What does the grep command do in Unix?
- a) Searches for a string in files
- b) Deletes files
- c) Renames files
- d) Copies files
Answer: a) Searches for a string in files
6. Which of the following commands is used to view the contents of a file in Unix?
- a) cat
- b) view
- c) display
- d) open
Answer: a) cat
7. What is the purpose of the ps command in Unix?
- a) To display currently running processes
- b) To print files
- c) To change directory
- d) To set permissions
Answer: a) To display currently running processes
8. What does the mkdir command do?
- a) Creates a new directory
- b) Deletes a directory
- c) Moves a directory
- d) Copies a directory
Answer: a) Creates a new directory
9. Which of the following commands is used to remove files in Unix?
- a) rm
- b) del
- c) remove
- d) erase
Answer: a) rm
10. How can you terminate a process in Unix?
- a) kill
- b) stop
- c) end
- d) terminate
Answer: a) kill
Conclusion
This brings us to the end of the article. We’ve covered a wide range of UNIX interview questions and answers in detail. We hope you found it helpful and feel prepared to excel in your upcoming UNIX interview.
Recommended Reading:
You can also practice top Coding UNIX interview Questions such as:
Do upvote our blogs. Head over to our practice platformCode360 to practice top problems, attempt mock tests, read interview experiences, interview bundle, follow guided paths for placement preparations, and much more!!
We wish you Good Luck! Keep coding and keep reading Ninja!!