Linux interview questions
The interviews for developers often include questions on the basics of the Linux and other Unix based operating systems. Others who have interviewed for various posts usually document these questions. The answers might vary from person to person but the concept remains the same and this can only be understood when the person is clear on the basics of Linux.
Linux is quite different from Windows but it has a wide acceptance in some fields. Since it is open source software operating system, Linux is basically free and is used as a cross-platform operating system, which can easily be installed in PCs, laptops, video game consoles and more. This is what opens up many applications for Linux and thus a demand for talented and knowledgeable professionals who are aware of the field they are working in. You will know a lot of the answers to the given questions if you have worked with the OS for a long time.
These questions and answers are sure to help you out in the interview by helping you understand the pattern of the questionnaire and types of questions asked. So, here are the questions and their answers.
Q1. What is Linux? How is it different from UNIX?
Ans. Linux is free open source multi-user operating system that is built on Linux kernel. Linus Torvalds released the first version of Linux operating system on September 17, 1991.
Some Difference between Linux and Unix Operating System:
|Linux is open source anyone can use it free of cost.||UNIX is copyrighted only big companies like IBM AIX and Sun Solaris and HP-UX use it|
|Linux is just a kernel.||Unix is a complete operating system|
|By default, Linux supports and use ext3 or ext4 file systems||Unix comes with jfs, gpfs (AIX), jfs, gpfs (HP-UX), jfs, gpfs (Solaris) filesystems|
|Linux Redhat Enterprise, Fedora Linux, Debian Linux, Suse Enterprise Linux, Ubuntu Linux are some popular Linux OS.||HP-UX, IBM AIX, Sun Solaris, Mac OS X are some Unix based operating systems|
|Linux is considered as most user-friendly||Apple OS X is most popular UNIX operating system for desktop usage.|
- Compare Linux with Windows?
Ans. Here are some of the differences between Linux and windows:
1) Linux is open source; the complete source code for Linux is available.
2) Linux is the GPL-licensed operating system, you are free to modify that software and use and even republish or sell it.
3) Download once and install it on as many PC you want.
4) Online peer support from the community via forums and online search.
1) Source code for windows is not available.
2) You can modify or redistribute Window operating system.
3) In Windows, you are bounded to use one license in One PC only. If you have to install it on other PC you need another License.
4) Paid to help desk support.
Q3. What is a kernel?
Ans. The kernel is the core of any operating system. Kernel acts as a middleman between computer hardware and operating system and controls everything on a computer. It is the first program that is loaded when a system starts.
Q4. What does uname command do?
Ans. <b>uname </b> is reporting command in Linux that is used to retrieve basic information about a computer’s hardware and software.
Synatax: uname [options]
Q5. What does whoami do?
Ans. The whoami command is basically the concatenation of “Who”, “Am” and “I”. This command is used in both, Linux as well as Windows to display the details of the login user or the owner of the currently running login session.
Q6. Please Explain LILO?
Ans. LILO comes from Linux Loader, which is a small program that manages dual boot and is, thus, also called as the boot loader. It was practically the default boot loader for quite a number of Linux distributions succeeding the fame achieved by loadlin. Although GRUB has grown increasingly popular recently, LILO and ELILO are still used widely.
Q7. What are the name and the UID of the administrator user?
Ans. The UID of the administrator user refers to a unique positive integer that is assigned by the system to each user. It is the user identity definition that is used by the system to identify each user. On the other hand, the username is an interface for the humans to recognize their account and login to the system.
Q8. What does ls -R do?
Ans. The Is-R option or command is used to flag the lists of the directory in a recursive manner.
Q9. What is LD_LIBRARY_PATH?
Ans. LD_LIBRARY_PATH is an environment variable set of directories separated by colons. This is where any library should be searched for before accessing the standard set of directories for search. This is especially useful when the user is using a non-standard or general library for any special purposes or when a new library is being debugged. A different library can be substituted for the execution of this command particularly.
Q10. What are the Linux boot files?
Ans. The Linux boot files are the configuration files, which are accessed and called during the system booting operation. The usage of this /boot/directory is standardized in the File System Hierarchy as it holds all the files used in booting the system- it is the first file to be called during the system boot. It usually contains Linux kernel files or boot loader files.
Q11. What does grep command do?
Ans. Searching for a pattern in a line or a file is fairly easy with the grep command. This command is executed when a particular pattern of characters must be searched. The grep filter searches one or more files as per the user command to search text strings using any expression.
Q12. What is the difference between absolute and relative path?
Ans. Specifying the exact location of a directory or file from any well-established directory, preferably the root directory is known as an absolute path. On the other hand, relative path specifies the location of the directory or file with reference to the current location or the present working directory (pwd).
Q13. What is Samba? Why is it used?
Ans. Samba is software suite with open source. It runs on Linux OS and Unix/Linux based platforms. It is a reimplementation of the Common Internet File System (CIFS) and the more central Server Message Block (SMB) protocol. It is the standard Windows interoperability suite, which means that the software is able to communicate the programs of Linux to the Windows clients just like a native application.
Q14. Which command will show you free/used memory? Does free memory exist on Linux?
Ans. There are many commands, which display the free or used memory on Linux. The easiest way to track memory usage on Linux is by using the ‘free’ command. Linux and other Unix based operating systems generally show less free memory as might be available. That is why Swap (a special type of memory) is available for use when the RAM is full.
Q15. What is the difference between soft and hard mounting points?
Ans. The NFS mount options basically define how a client should handle or face a server crash or fail. In case of the soft mount, the client can report an error without waiting for a response from the NFS server. But this could also result in data corruption or data loss too. On the other hand, in case of the hard mount, the NFS file system repeatedly contacts the server until it receives a response. Once it reaches the server, the program will continue execution from the same point where it was stuck during the server crash.
Q16. What is SSH? How to connect to a remote server via SSH?
Ans. SSH stands for Secure Shell, which is a protocol for securely logging onto remote systems. It is the most common and simple way to access the remote Linux based servers. In order to do this, you must own a domain name and IP address.
Q17. What is Virtual Memory?
Ans. When the physical memory runs short, the computer, or rather the operating system makes use of both, hardware and software to compensate for the shortage of physical memory. It transfers the data from RAM to the disk space.
Q18. List the basic components of Linux?
Ans. There are three basic components of Linux:
Kernel: This is the core part of the Linux OS.
System Libraries: These are special programs, functions or methods. The application programs and system utilities access the features of the kernel.
System utilities: These are programs, which are responsible for accomplishing specialized tasks at the individual level.
Q19. What is a shebang line?
Ans. The shebang or bang line is the absolute path from the root to the Bash interpreter. In a text file, the program loader parses the text in the initial line following the shebang as an interpreter directive.
Q20. What does the command env do?
Ans. The env command is a shell command, which can be used to print out a list of the existing environment variables, or for running another program in a custom environment without altering the current one.
Q21. What does chmod +x FILENAMEdo?
Ans. The chmod command is an abbreviation for Change Mode. This command is extremely useful for changing the permission for Files and folders located in Linux/Unix. File/Directory permission, which is generally Write, Read or executable for any user, group or others.
Q22. What is CLI?
Ans. CLI is short for Command Line Interface and it is a human-computer interface. It is usually in sharp contrast to the Graphic User Interface (GUI), which is also used widely. In case of Linux, the GUI is used as an external wrapper to the basic CLI.
Q23. What is the difference between Telnet and SSH?
Ans. SSH is basically a network protocol, which is used to remotely access and manage any device distantly. The chief difference between SSH and Telnet is that SSH makes use of encryption, which implies that the entire data transmitted over a network is secure from snooping. Telnet is not as secure though. Like Telnet, a user who wants to access a remote device must install an SSH client.
Q24. What does set -o do?
Ans. Set is an inbuilt shell, which displays all the shell variables including the environment variables.
Q25. State the difference between swap partition and a swap file?
Ans. The Linux Operating System uses reserved disk block in the hard drive to swap. This is known as Swap Partition as no other files can be traced in the swap partition. In case of Windows OS, the swap space or partition is called swap file or page file.
Q26. What does comm do and how to use it?
Comm produces a three-column output. It is basically a utility, which is used to compare two files for distinct and common lines.
Q27. What is the full form of grep?
Ans. Grep stands for global regulation expression point. The command-line utility, grep, is used for searching data sets in plain-text for lines that match an expression which is used regularly.
Q28. What is an A record, an NS record, a PTR record, a CNAME record, an MX record?
Ans. An NS record is operated to give a subdomain to a set of name servers. Whenever a user delegates a domain to DNSimple, the TLD authorities automatically place NS records for that domain in the TLD name servers.
The PTR record is basically used as a spam filter and is used to authenticate the incoming messages. An A record should always exist for the PTR records.
CNAME stands for Canonical Name, which is what this record provides to an alias name.
MX stands for Mail Exchanger and the MX record is a special type of resource record in the DNS (Domain Name System). It specifies a mail server, which is completely responsible for accepting the messages via email on behalf of the recipient’s domain. A preference value is used to prioritize the mail delivery in case of multiple servers.
Q29. What does Sar provide? Where are Sar logs stored?
Ans. SAR is an abbreviation for System Activity Report. This command is used to collect data, report and save the usage of CPU, a Memory unit, input, and output in Linux.
Q30. What is a zombie process?
Ans. A zombie process is also known as a defunct process. It is a process in the terminated state and has completed execution via the exit system call but still has an entry in the table of processes.
Q31. What is a Split-Horizon DNS?
Ans. This is the facility of the DNS implementation to provide the user with DNS information. It can provide a strong mechanism for privacy management and overall security.
Q32. What is a typical size for a swap partition under a Linux system?
Ans. The recommended swap size is of 20% of RAM for modern systems. If hibernation is used, the swap should have a minimum of the same amount of space as the physical RAM.
Q33. What is an inode?
Ans. An inode is a data structure in the Linux file system. It stores all the available information on the file except for the name and the actual data stored in the file. This allows the system to use the data efficiently.
Q34. What is the difference between an environment and a local variable?
Ans. Shell variables are local to the region they are defined in and are only available in the current shell. On the other hand, the user defines the environment variables interactively or in a startup file. A local variable can be made available as an environment variable by using ‘export VARNAME’.
Q35. What is SSH port forwarding?
Ans. SSH port forwarding creates a secure connection between a remote machine through which services can be relayed and the local computer, which gives the commands. It is also called SSH tunneling and is used for transmission of information, which does not necessarily require an encrypted protocol.
Q36. What does the immutable bit do to a file?
Ans. Making the file immutable by associating the immutable bit attribute to it prohibits even the root user from deleting it.
Q37. What does ps do?
Ans. The process status command or ps is used to provide information about the currently running status processes in the system. This includes the PID (process identification number), which is unique to every process or task.
Q38. Describe the mknod command and when you’d use it.
Ans. The mknod command is employed to create device files that can act strangely as compared to normal files. Device files are kept in the directory /dev, and unlike normal files, these device files are ones that the kernel knows about, and reads or writes to.
Q39. What are hard links?
Ans. A hard link is simply an additional name for an existing file on Linux Operating System. They can also be created for other hard links.
Q40. What is “nohup” used for?
Ans. The nohup command is a POSIX command used to ignore the HUP signal. The HUP signal is, by standard, the way a terminal warns dependent processes of logout.
Q41. What is a swap?
Swap is the added space, which is used when the physical memory is full. The inactive pages and unnecessary data are moved to Swap Partition when more memory is needed in RAM.
Q42. What is The SSL Handshake?
Ans. The SSL handshake enables the SSL client and the server to establish the secret keys with which they communicate. SSL or TLS makes use of the shared key for the symmetric encryption of messages, which is much faster than an asymmetric encryption.
Q43. What is the TCP handshake?
Ans. This is a three-way handshake in terms of the transmission control protocol, which uses the SYN-SYN-ACK method.
There are many more questions, which could be asked by the interviewer and one might want to elaborate on some replies to demonstrate their own knowledge. The answers were curated from multiple sources and one can read more on the web about each topic if they are unfamiliar with it. These questions are not mandatory but just an example of what may come in the interview. But maximum basic questions may come as mentioned above. Hope they are helpful to you for your interview. The key is not to go in-depth but explain the concept. A good preparation and a smart approach may help you get through this interview. All the best!