10 Unix Interview Questions You Should Be Ready For
Despite being one of the oldest operating systems around, with its roots going all the way back to the beginning of the ‘70s, UNIX is still very popular today. UNIX-based systems are widely used in environments that require maximum reliability and scalability, so don’t be amazed if you come across a lot of job listings for positions that require UNIX knowledge. Whether we are talking about a position that implies just some basic knowledge of UNIX or one that requires you to be able to write code in your sleep, one thing is for sure: UNIX is here to stay, so if you haven’t done it already, grab some books and start learning. Considering the fact that UNIX is based on the C programming language, and the two share a lot of common ground, an introductory course to C may prove to be a great starting point.
When you feel confident enough to make a move, put together an awesome resume and prepare for an interview for a job in this field. This article will walk you through the most common UNIX interview questions. Ready, set, GO!
Basic Theory Questions
1. What is UNIX?
It may sound as a trivial question, but you’d be amazed just how many people fail to give a clear definition, because simply stating that “Unix is an operating system” is not likely to impress the interviewer. The correct answer should look something like this:
UNIX is a multi-user multitasking-optimized operating system that can run on various hardware platforms.
2. How is UNIX different from Linux?
Linux is basically an open-source clone of UNIX so, while a lot of similarities between the two operating systems do exist, there are also 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.
3. What is a kernel?
The kernel is the program that acts as a middle layer between software and hardware. When a program requires access to certain resources or processing power, the kernel is responsible for sending the correct signals to the CPU and managing all other running programs and services so that the resources are correctly allocated and no conflicts occur.
4. What is the difference between multi-user and multi-tasking?
Multi-tasking means that a user can run multiple tasks simultaneously on a single machine, whereas multi-user means that multiple users can operate simultaneously on a machine.
5. What is a UNIX shell?
A UNIX shell is an interface that acts as a command interpreter, translating user input into machine-understandable language and then passing it to the kernel for execution.
Once you ace the basic stuff, the interviewer is most likely to move on to some questions involving commands. Keep in mind that his role is not to see how good you are at memorizing commands, but rather how well you understand what those commands do and determine your ability to choose the right command in a certain situation. In order to successfully pass this part of the interview, make sure you formulate your answers as clear and as detailed as possible. You should consider taking a course to improve your communication skills prior to the interview.
1. What command can you use to display the first 3 lines of text from a file and how does it work?
There are two commands that can be used to complete this task:
head -3 test.txt – this uses the “head” command, along with the “-3” parameter that indicates the number of lines to be displayed;
sed ‘4,$ d’ test.txt – this command uses the Sed text editor to perform the task. If the command was simply “sed test.txt” the whole file would have been displayed; however, in our example the delete parameter was used (d) to make Sed delete everything between the 4th and the last line (defined by the $ parameter), leaving only the first 3 lines of the file. It is important to mention that Sed does not actually delete the lines from the file itself, but just from the output result.
2. How can you remove the 7th line from a file?
The easiest way is by using the following command: sed -i ‘7 d’ test.txt
Unlike the previous Sed command, this command also has the “-i” parameter, which tells Sed to make the change in the actual file.
3. What is piping?
Piping is a technique that consists of entering two or more consecutive commands, separated by the pipe symbol “|”. Once the first command is executed, its output will be used as input for the second command, the output of the second command will be used as input for the third and so on, until the whole chain of commands is executed.
4. How do you reverse a string?
You can reverse a string by using a simple piping of two commands: echo “Mary” | rev
The first command will generate the output “Mary”, which will become the input for the rev command, making it return the reverse: “yraM”.
5. How can you find out what a command does?
You use man <command-name> in order to bring up the manual page that describes the actions of the specified command and any other additional options and parameters that command might have.
These are some of the UNIX questions interviewers usually ask during basic interviews. However, if the interview is for a more technical position, you can expect to encounter questions that are more difficult; still, there is no reason to panic, as UNIX itself was created to be quite logical, so a good knowledge of the basic commands and a bit of imagination can help you get the job done.
Check out this online course to learn how to use the UNIX command line to get the most out of OS X – yes, the OS X that runs on your Mac, which is UNIX based by the way. If this doesn’t convince you that UNIX can be simple and intuitive, nothing else will.
Unix students also learn
Empower your team. Lead the industry.
Get a subscription to a library of online courses and digital learning tools for your organization with Udemy for Business.