12 Tricky Linux & Unix Interview Questions to Test Programmers in May 2023

Because of the influence of the original Unix operating system, and its closest successor, Linux, it’s hardly possible to go for a job interview in programming without being given at least some Linux or Unix interview questions. Here are 12, with answers, to get you prepared for your interview.

Unix is a hardy perennial of operating systems, first devised almost half a century ago in the late 1960s in Bell Labs. With the exception of the Microsoft NT systems, Unix’s DNA is everywhere, most notably in Linux, but also the Mac OS X, iOS, Android, Chrome, even in the Orbis system in Playstation 4. And that’s why, when going for a job in programming, that it’s good to know about Unix interview questions and especially the workings of its descendant Linux.

Even if you consider the design philosophy underpinning Unix—it’s a collection of small modular utilities, each undertaking one task as part of a complex entirety—you can appreciate the continued relevance of the ‘original of the species’ Unix.

This is why there are so many similarities between a Mac OS X terminal or file system, and Linux’s, and why they are so different from Windows. The former two were inspired by the Unix operating systems, where as Windows does not.

The original Unix has two offshots: on the open-source side, BSD led ultimately to iOS, Orbis as well as the GNU project that birthed MINIX, which inspired Linux and then to GNU/Linux, which is the foundation stone for Android, Chrome, Steam and others.

Meanwhile, the commercial descendants included those systems developed by large corporations and licensed as their own respective variants of Unix. These, some of which are still in operation today, include AT&T UNIX, SCO UnixWare, Sun Microsystems Solaris, HP-UX, IBM AIX, and SGI IRIX.

And while the march of Unix toward industry standard global domination was halted by DOS and IBM-compatible computers, especially Microsoft’s variant of DOS (which led to Windows NT and eventually to Windows XP), its influence endures, especially in Linux.
Below we have compiled a list of 12 questions shared online by Unix and Linux developers and we encourage you to study them before you go for your interview. 

To follow up on this article, there are numerous books about Unix and Linux available online. A Practical Guide to Linux Commands, Editors, and Shell Programming (3rd Edition) by Mark G Sobell who is regarded as one of the best sources on essential Linux commands. Another is The Linux Command Line: A Complete Introduction by William E Shotts Jr, which is highly rated and recommended for essential shell commands. Last but by no means least is How Linux Works: What Every Superuser Should Know, which is another highly rated Linux guide for programmers. 

linux interview questions

Image Source:
Check Price >

12 Linux and Unix Interview Questions for Programmers & Developers

So, as we have seen, the influence of Unix remains palpable and potent. Not to labour the point, but Linux is the most popular descendant, and displaced the SUS-certified Unix variant in the early 1990s. However and perhaps most significantly of all, Android, which is the most widely used mobile operating system in the world, is based on Linux. So, while Unix has a long history, experts will tell you online that interviews for Java programming, Android and other development jobs are almost bound to include Linux and Unix interview questions.

What follows is a list of 12 Linux and Unix interview questions to get you into a state of readiness for what you might face during an interview. They range in difficulty from easy to complex, but none should be under-estimated. Good luck, Linux & Unix AGENTs!

1. What is UNIX?

As the Udemy team point out, this may sound like a no-brainer, but it’s incredible just how many candidates struggle in an interview to give a clear definition of Unix. Udemy’s answer suggestion is as follows:

UNIX is a multi-user multitasking-optimized operating system that can run on various hardware platforms.

Linux & Unix Interview Questions & Answer Source: Udemy

2. How do you find all the links in a folder in UNIX or Linux ?

According to Java67.com, this is one of the trickier UNIX interview questions, as there is no specific command to find all symbolic links. The ln command creates and updates soft links, but nothing gives all the links in a directory.
The one to use is the ls command which lists everything in the directory; then you need to list all the links, as they start with “l” as first characters. The actual UNIX command to find all links in a directory is:

[email protected]:~ ls -lrt
total 2.0K
-rw-r--r--  1 Linux Domain Users  0 Dec  6  2011 a
drwxr-xr-x+ 1 Linux Domain Users  0 Sep 19 12:30 java/
lrwxrwxrwx  1 Linux Domain Users  4 Sep 19 12:31 version_1.0 -> java/
[email protected]:~ ls -lrt | grep '^l'
lrwxrwxrwx  1 Linux Domain Users  4 Sep 19 12:31 version_1.0 -> java/
Linux & Unix Interview Questions & Answer Source: Java67.com

3. Technical coding questions

Be sure to research technical Unix interview questions, for your skills will undoubtedly put you to the test. Toptal provides a typical question: How would you count every occurrence of the term “potato” in all the files appearing under the current directory,

$ grep -orI potato . | wc -l

and its subdirectories, recursively?
Answer: To list every occurrence of the term “potato” on a separate line, one must run

 grep -o potato <path>

Adding the r flag to the command makes the search recursively process every file under the given path, and the I flag ensures that matches in binary files are ignored. In addition, the w flag can be included to match the exact term only, and ignore superstrings such as “potatoes”, and to make the search case-insensitive, the i flag can be added as well:

$ grep -iworI potato . | wc -l

The number of lines yielded by this grep command is the number of occurrences of the desired term, which can then be counted by piping it into the wc -l command.

Linux & Unix Interview Questions & Answer Source: Toptal.com

4. How do you print/display the first line of a file?

TheProfessionalsPoint blog points out that there a number of ways to answer this question, but the easiest way to do it is by use of the [head] command.

$> head -1 file.txt

Using [head -2] would print the first 2 records of the file.
Another method is the [sed] command, a powerful text editor which can be used for various text manipulation purposes like this.

$> sed '2,$ d' file.txt

The ‘d‘ parameter instructs [sed] to delete all the records from display from line 2 to the last line of the file (represented by $). The command does not actually delete the lines. Rather, it does not display the specified lines on a standard output screen, so the user will see only the remaining line, the first line.

Linux & Unix Interview Questions & Answer Source: TheProfessionalsPoint.Blogspot.ie

5. What are shared, slave, private, and unbindable mountpoints?

A mountpoint that is shared may be replicated as many times as needed, and each copy will continue to be the exact same. Other mount points that appear under a shared mount point in some subdirectory will appear in all the other replicated mount points as it is.
A slave mountpoint is similar to a shared mount point with the small exception that the “sharing” of mount point information happens in one direction. A mount point that is slave will only receive mount and unmount events. Anything that is mounted under this replicated mount point will not move towards the original mount point.
A private mountpoint is exactly what the name implies: private. Mount points that appear under a private mount point will not be shown elsewhere in the other replicated mount points unless they are explicitly mounted there as well.
An unbindable mountpoint, which by definition is also private, cannot be replicated elsewhere through the use of the bind flag of the mount system call or command.

Linux & Unix Interview Questions & Answer Source: Toptal.com

6. How to run a program in the background in Unix or Linux ?

As the Java67.com team point out, this is an easy Unix or Linux interview question, but only when you know. You can use &amp; to run any process in the background and then use jobs to find the job id for that process. The fg and bg commands bring that process to the foreground and background respectively. Java67.com recommends candidates to read the book How Linux Works: What Every Superuser Should Know, to learn more about running a process in the background.

unix interview questions

Image Source:
Check Price >

Linux & Unix Interview Questions & Answer Source: Java67.com

7. How is UNIX different from Linux?

Udemy advises that while Linux is an open-source clone of UNIX, with a lot of similarities, the candidate should be aware that there are a lot of differences.  The main advantage of UNIX is that all the core components of the operating system come from the same vendor, which means greater overall stability and better software support from vendors. UNIX releases are more stable and consistent than Linux releases, making UNIX the better choice for enterprise use.

Linux & Unix Interview Questions & Answer Source: Udemy

8. What is the meaning of ‘644 permission’ for a file?

As the Java67.com team points out, to answer UNIX interview questions such as this depends on your knowledge about the basics of UNIX files and directories. 644 represents permission 110 (for the owner), permission 100 (for a group) and 100 for others. This translates into read + write access for the creator of the file (the owner), and read-only permission for the group and others.
The team further explains that in Unix, whenever a file is created, the file creation process uses default permission 666 (and 777 for a directory). The user is able to restrict permissions for that file or directory through the unmask command. For example, a common unmask value is 022, which will grant the file read + write permission for the owner and group, but read-only for group members and other.

Linux & Unix Interview Questions & Answer Source: Java67.com and JavaRevisited.Blogspot.com

9. What is a Unix shell? Is Bash the only Unix shell?

The experts at Toptal.com provide comprehensive answers to these and other Unix interview questions. Firstly, they define a Unix shell as software that provides a user interface for the underlying operating system. Unix shells typically provide a textual user interface – a command line interpreter – that may be used for entering and running commands, or create scripts that run a series of commands and can be used to express more advanced behaviour.
Bash is not the only Unix shell, but just one of many. Short for Bourne-Again Shell, it is also one of the many Bourne-compatible shells. However, Bash is arguably one of the most popular shells around. There are other, modern shells available that often retain backwards compatibility with Bash but provide more functionality and features, such as the Z Shell (zsh).

Linux & Unix Interview Questions & Answer Source: Toptal.com

10. How do you check all the running processes in Unix?

The standard command to see this, according to TheProfessionalsPoint blog, is [ps]. However, [ps] shows only a snapshot of the processes at that instance. If you need to monitor the processes for a certain period of time, and refresh the results in each interval, consider using the [top] command.

$> ps –ef

If you wish to see the percentage of memory usage and CPU usage, then consider the switches below:

$> ps aux

If you wish to use this command inside some shell script, or if you want to customize the output of [ps] command, you may use “-o” switch, as in the example below. By using “-o” switch, you can specify the columns that you want [ps] to print out.

$>ps -e -o stime,user,pid,args,%mem,%cpu
Question & Answer Source: TheProfessionalsPoint.Blogspot.ie

11. Your application home directory is full. How do you determine which directories are using most space?

By using the disk usage (DU) command in Unix, according to TheProfessionalsPoint blog. For example,

du –sh . | grep G

will list down all the directories which have GIGS in Size.

Linux & Unix Interview Questions & Answer Source: TheProfessionalsPoint.Blogspot.ie

12. What is a Linux null (or Blackhole) route? How can it be used to mitigate unwanted incoming connections?

A Linux null (or Blackhole) route is a type of routing table entry which, upon matching a packet, discards it without forwarding the packet any further or sending any ICMP.
Using this technique, it is possible to block an IP (or range of IP addresses) by running a simple command. For example, blocking can simply be done with the following command:

# ip route add blackhole
Linux & Unix Interview Questions & Answer Source: Toptal.com


This website uses cookies. Continued use of this website indicates that you have read and agree to our Terms & Conditions and Privacy Policy.