Greetings! Today, we are listing down thirty essential Linux questions every beginner should know. It’s our attempt to unravel the core Linux areas so that even a beginner can feel a bit confident during a faceoff in a Linux interview.
For some of us, since our college times, learning Linux has been a nightmare. But now is the time when you can’t ignore it anymore. It’s one of the areas where most IT companies look for candidates with solid Linux skills. Also, you may have a dozen interviews lined up, so you are already short of time.
But you shouldn’t worry, just try to make the most out of the remaining time. And read all the essential Linux questions mentioned in this post. We’ve tried adding the gist of all important Linux concepts and commands into this tutorial.
Now, you can proceed to read the most important Linux interview questions and answers. And get aware of the latest trends in Linux interviews.
30 Questions for Better Results in a Linux Interview
Ans. Linux is an operating system based on UNIX and was first introduced by Linus Torvalds. Most servers use Linux as their Operating System. It runs on different hardware platforms manufactured by Intel, MIPS, HP, IBM, SPARC, and Motorola. Another striking element in Linux is its mascot, a penguin figure with the name Tux.
The popularity of Linux is mainly because of the following reasons.
- It is free and open-source. We can download Linux for free and customize it as per our needs.
- It is very robust and adaptable.
- It is accompanied by an immense amount of libraries and utilities.
Ans. BASH is a short form for Bourne Again Shell. Steve Bourne developed it as a replacement for the original Bourne Shell (represented by /bin/sh). It combines all the features from the original version of Bourne Shell, plus additional functions to make it easier and more convenient to use. Since then it has been adapted as the default shell for most running systems.
Ans. The core of the Linux operating system is Kernel. It is broken down into Shell, Command, Script, and Terminal. Shell is the Command Line Interpreter.
A Command is an instruction given to the Computer by the user to perform a task. A Script is a collection of commands stored in a file, and the terminal is the CLI.
Also Read: Linux Commands Cheat Sheet
Ans. Linux is free and open-source software (allows programmers to program with Linux, not around it). Linus Torvalds and the community developed its Kernel.
UNIX, on the other hand, is a copyrighted name. Only big companies can access and use its copyright and name.
For example, the products like IBM AIX, SunSolaris, and HP-UX are all UNIX-based Operating Systems.
Ans. LILO is a bootloader for Linux.
It is used mainly to load the Linux operating system into main memory so that it can begin its operations.
Ans. All files have their description stored in a structure called “inode”. It stores information about the size of the file, access and modification times, file permissions, and so on.
In addition to the above, it also holds the pointer to the data blocks of the files.
Ans. A swap space is a certain amount of space used by Linux to temporarily hold some programs that are running concurrently.
It is useful when RAM does not have enough available memory to hold all the programs that are executing at the same time. This space gets free when the execution of the program is complete.
Ans. Open source allows you to distribute your software including the source code, freely to anyone who is interested. Anyone can help by adding new features to the software and can even debug and correct errors present in the source code.
They can even make it run better and then redistribute the enhanced source code freely again. In this way, open-source benefits everyone in the community.
Ans. Following are the main differences between the Console.
- BASH commands are case-sensitive while DOS commands are not.
- Under BASH, /character is a directory separator and acts as an escape character. Under DOS, /serves as a command argument delimiter and is the directory separator.
- DOS follows a naming convention for files, where it allows a maximum of 8 characters of filename followed by a dot and then 3 characters for the extension. However, BASH follows no such convention.
Checkout: How to Create a Service in Linux
Ans. The main differences between the two are as follows.
- TCP stands for Transmission Control Protocol. It first establishes the connection before sending data and is thus called a connection-oriented protocol. It controls the flow of data and also guarantees the delivery of packets.
- UDP stands for User Datagram Protocol. It simply sends datagrams onto the wire. There is no ordering of packets, if some of the packets get lost in the way or they arrive in bad order then there is no way to request those packets again. Thus it is called a connection-less protocol. Some services like DNS resolution, SNMP, DHCP, RIP, and VOIP prefer to use UDP for their speed due to less network overhead. Any errors that occur during data transfer get handled on the application layer rather than the network layer.
Ans. A client application requests an IP address from the name server usually by connecting to UDP port 53. The nameserver will attempt to resolve the FQDN based on its resolver library, which may contain authoritative information about the host requested or cached data about that name from an earlier query.
If the nameserver does not already have the answer, it will turn to root nameservers to determine the authority for the FQDN in question. Then, with that information, it will query the authoritative nameservers for that name to determine the IP address.
Ans. The root is like a system administrator account that grants full control of the system. It can create and maintain user accounts and set different permissions for each account. With root access, you have access to all commands and files on the system. It is the default account that gets created at every new installation of Linux.
We can refer to it as the root user or a super user. There is a special command named <su> (for “super user”, or “switch user”) that allows switching over to the root account on the command line. If you enter the correct root password, you enter into the root account to execute commands with full system privileges.
Ans. From a command shell, execute the concatenate command to provide the memory usage information.
This command displays the following output on the terminal.
This output tells about the total memory available for use.
Ans. MX (Mail eXchanger) records are like an address for your domain’s email. It tells the rest of the internet about the mail server responsible for accepting email messages on behalf of a recipient’s domain.
It is also a kind of preference value that determines the server for processing the mail delivery if multiple servers are available. This number can assume any value between 0 to 65535.
The MX record with the lowest number will have more weightage over the others. The user can also set multiple e-mail servers with the same preference value for load balancing.
Ans. There are seven steps in the boot-up sequence.
- BIOS (basic input/output system) – Executes the MBR where Boot Loader sits.
- MBR – Master boot reads Kernel into memory.
- GRUB(Grand Unified Bootloader)- Kernel starts the Init process.
- Kernel – It executes the
/sbin/initprogram. Then, the init process reads the
inittabfile and executes the
- The init script – It is the
rcscript to start services for reaching the default run level.
- Run-level programs – These programs execute from the
Bookmark it: 7 Linux Commands for Programmers
Ans. The standard size for a swap partition is twice the amount of physical memory available on the system.
If this is not possible, then the minimum size should be the same as the amount of memory installed.
Ans. Linux provides
sed command and <vi-editor> to perform the “search and replace” action for a pattern.
1. Using sed command.
The sed command searches for a particular pattern in the file. And, if a match occurs, then it replaces the text with the target string mentioned in the command.
Syntax for sed “Search and Replace”-
sed 's/SEARCH/REPLACE/OPTIONS' FILE.txt
- “s” is used to search for a pattern.
- “/” – It’s a delimiter. There are some alternatives for “/” like
# % @ :.
- SEARCH – Mention the search pattern here.
- REPLACE – Define the string that will replace the search pattern.
- OPTIONS – This command comes with the following options.
- <g> – Helpful when the user requires replacing ALL the SEARCH instances with REPLACE string.
- <i> – To search a pattern in case insensitive mode.
- <n> – Unlike option <g>, <n> requires replacing only the nth occurrence of the search pattern.
- <p> – prints only the line containing the search pattern.
- <w> – To edit the original file, you may use option <i>. But, in case you want to write the output to another file, keeping the original file intact, you can use option <w>. Using redirection operators (> or >>) is another way.
2. Using vi editor.
vi also has powerful search and replace capabilities. To search any string in a file, just type a colon (:), “s”, forward slash (/), and the search string in the command mode of the vi editor. What we type will appear on the bottom line of the display screen.
On pressing ENTER, the area containing the matching text will get highlighted, if it exists.
The formal syntax for searching is:
The syntax for replacing one string with another string in the current line is:
:s/search pattern/replace string/
Following is the command to replace all the occurrences of the search string in the entire text. You have to add a “%” in front of the “s” as:
:%s/search pattern/replace string/
Ans. Yes, it works in Linux just like Windows. This key combination when used performs a system restart.
The only difference is that no confirmation pop-up occurs and therefore the reboot is immediate.
Ans. First, you use the –L switch to view all the currently present rules and then –F to flush them.
Ans. A system administrator or the owner of a file or directory can grant permission using the <chmod> command.
The user adds permission to a file using the “+” symbol and denies permission using the “–” symbol, along with one or more of the following letters.
- -w(write), and
For example the command.
chmod go+rw FILE1.TXT
It grants read and write access to the file FILE1.TXT, which is accessible to both groups and others.
Ans. Shell is a user program or it’s the environment provided for user interaction. It is a command language interpreter that executes the commands read from the standard input device like a keyboard or from a file.
Shell is not part of the system kernel but uses the system kernel to execute programs and create files.
The following Shells are available with Linux SH, BASH, CSH, TCSH, and KSH. Other functions of a shell include scripting capability, path memory, multitasking, and file handling.
Ans. Serial ports are identified as /dev/ttyS0 to /dev/ttyS7.
These are the names equivalent to COM1 to COM8 in Windows.
Ans. Zombies are essentially premature processes whose mature parent processes died without reaping their children. Zombie processes are already dead.
The kill command or system call has no effect on it. It’s just an entry in the process table. None of the resources like memory, running code, or any active file have any association with a zombie.
Ans. When a process dies, all resources are cleaned up including the entry in the process table. This entry is kept around, forming a zombie, to allow the parent process to track the exit status of the child.
The parent determines the exit status by calling wait() syscall. Calling wait() drives the zombie to disappear and this means reaping the child. Thus we can say that a zombie comes into existence when a process dies, but its parent hasn’t called wait yet.
Ans. An existing zombie process can be determined by running “ps aux” and then looking for a Z in the STAT column.
Ans. There are two ways to terminate a zombie.
- If the parent is alive, then it must call a wait() syscall to clean up a zombie.
- In the other case, if the parent dies before the child or dies without reading the child’s status, the zombie’s parent process is set to <init> (the process with PID 1). Now, the <init> has to ensure to call the wait() for the occupied zombie process.
Ans. Linux assigns numbers at the end of the identifiers assigned to drives.
For example, if the first IDE hard drive had three primary partitions, they would be named/numbered as </dev/hda1>, </dev/hda2>, and </dev/hda3>.
Ans. The “hash” is one of a bash shell’s built-in commands. It makes use of a hash table to keep the list of pathnames for the commands executed in the shell. Whenever you run any command, the shell starts searching for it in the variable $PATH.
However, if the command is present in the hash table, then the Shell picks it from there for execution. The hash table stores all the entrances of each command used so far in that shell.
$ hash hits command 1 /usr/bin/cat 2 /usr/bin/ps 4 /usr/bin/ls
You can delete a particular command from a hash table using the -d option, and the -r option to reset the complete hash table.
$ hash -d cat $ hash hits command 2 /usr/bin/ps 4 /usr/bin/ls
Ans. It serves as an alternative to the action of minimizing and maximizing different windows that need to focus on the current desktop. Every desktop that uses this feature behaves like a clean slate where you can open one or more programs.
It is simple to shuffle between virtual desktops keeping the programs intact in each one of them. Rather than, minimizing/restoring these programs again and again while focusing on them.
Ans. There is an icon present in the upper left-hand corner of the program window that looks like a pushpin. e.g. In Ubuntu.
On pressing this button, the application will get pinned, causing it to appear on all virtual desktops and in the same position on their screen.
Also Read: 30 Basic Linux Questions for Freshers
Summary – Essential Linux Questions for Interview
We are hopeful that the above essential Linux questions and answers will help you immensely. And you’ll do well in your upcoming interviews.
It would be great if you let us know your feedback on this post.
Also, you can ask us to write on a topic of your choice. We’ll add it to our writing roadmap.
Lastly, if you enjoyed the post, then please care to share it with friends and on social media.