Essential Linux Questions and Answers for Beginners

Here we come up with another post covering thirty essential Linux questions and answers for freshers. 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 of 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 into this Linux tutorial.

And if you already have a basic understanding of Linux, then do attempt the below listed Linux quizzes. It’ll help you in practicing what you know and lift your confidence level which is the key to success in any interview.

Now, you can proceed for reading the essential Linux questions and answers. More importantly, you would be aware of the pattern of questions asked during technical interviews.

Essential Linux Questions and Answers for Beginners.

Essential Linux Questions and Answers for Freshers

Essential Linux Questions for Freshers.

Q-1. What is Linux and why is it so popular?

Ans. Linux is an operating system based on UNIX and was first introduced by Linus Torvalds. Most servers use Linux as its 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 name Tux.

The popularity of Linux is mainly because of the following reasons.

1. It is free and open-source. We can download Linux for free and customize it as per our needs.
2. It is very robust and adaptable.
3. It accompanies with an immense amount of libraries and utilities.

 

Q-2. What is BASH?

Ans. BASH is a short form for Bourne Again Shell. Steve Bourne developed it as a replacement to 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.

 

Q-3. What is the core of Linux Operating System?

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 Terminal is the CLI.

 

Q-4. What are the basic differences between UNIX and Linux Operating Systems?

Ans. Linux is free and open-source software (allows programmers to program with Linux, not around it). Linus Torvalds and community developed its Kernel.

UNIX, on the other hand, is copyrighted name. Only big companies can access and use its copyright and name.

For example, the products like IBMAIX, SunSolaris, and HP-UX are all UNIX-based Operating Systems.

 

Q-5. What is LILO?

Ans. LILO is a boot loader for Linux.

It is used mainly to load the Linux operating system into main memory so that it can begin its operations.

 

Q-6. What is an INODE?

Ans. All files have its 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 above, it also holds the pointer to the data blocks of the files.

 

Q-7. What is a swap space?

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.

 

Q-8. What is the advantage of open source?

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.

 

Q-9. List down the key differences between BASH and DOS.

Ans. Following are the main differences between both the Console.

1. BASH commands are case-sensitive while DOS commands are not.
2. 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.
3. DOS follows a naming convention for files, where it allows maximum 8 characters of filename followed by a dot and then 3 characters for the extension. However, BASH follows no such convention.

 

Q-10. What are the differences between TCP and UDP?

Ans. The main differences between the two are as follows.

1. TCP stands for Transmission Control Protocol. It first establishes the connection before sending data and thus called as connection-oriented protocol. It controls the flow of data and also guarantees the delivery of packets.
2. UDP stands for User Datagram Protocol. It simply sends datagrams on to 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 as connection-less protocol. Some services like DNS resolution, SNMP, DHCP, RIP and VOIP prefer to use UDP for its speed due to less network overhead. Any errors that occur during data transfer gets handled on the application layer rather than the network layer.

 

Q-11. How does DNS resolution determine the IP Address?

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 authoritative for the FQDN in question. Then, with that information, it will query the authoritative nameservers for that name to determine the IP address.

 

Q-12. Describe what is a root account in Linux?

Ans. It is like a system administrators account that grants full control on the system. It allows creating and maintaining user accounts and assigning different permissions for each account, has 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 it as the root user or a super user. There is a special command named su (for “super user”, or “switch user”) that allows to switch 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.

 

Q-13. Mention the command to find out how much memory is available for use with Linux.

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. 

 

Q-14. What do you know about the MX record?

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 which 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.

 

Q-15. What are the steps that define the Linux boot-up sequence?

Ans. There are seven steps in the boot-up sequence.

1. BIOS(basic input/output system) – executes the MBR where Boot Loader sits.
2. MBR – Master boot reads Kernel into memory.
3. GRUB(Grand Unified Bootloader)- Kernel starts Init process.
4. Kernel- It executes the /sbin/init program. Init reads inittab, executes rc.sysinit.
5. Init – rc script then starts services to reach the default run level.
6. Run level programs – these programs execute from /etc/rc.d/rc*.dl

 

Q-16. What is the recommended size for a swap partition under a Linux system? 

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.

 

Q-17. How do you search for a pattern and then replace it in an entire file?

Ans. Linux provides <sed> command and <vi-editor> to perform “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”-

where,

“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 – “s” command comes with following options:
         <g>: helpful when the user requires replacing ALL the SEARCH instances with REPLACE string.
        <i> : its role is 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. For searching 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:

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:

 

Q-18. Does the following key (Ctrl+Alt+Del) combination works on Linux?

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.

 

Q-19. How do you perform list and flush of all IP tables?

Ans. First, you use the –L  switch to view all the currently present rules and then –F to flush them.

 

Q-20. How do you change permissions under Linux?

Ans. A system administrator or the owner of a file or directory can grant permission using the chmod command.

User adds permission to a file using “+” symbol and denies permission using “–” symbol, along with one or more of the following letters:
-u(user),
-g(group),
-o(others),
-a(all),
-r(read),
-w(write), and
-x(execute).

For example the command.

It grants read and write access to the file FILE1.TXT, which is accessible to both groups and others.

 

Q-21. What is a shell? List the name of different Shells available in Linux.

Ans. Shell is a user program or it’s 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 system kernel but uses the system kernel to execute programs and create files.

Following Shells are available with Linux SH, BASH, CSH, TCSH, and KSH. Other functions of a shell include scripting capability, the path memory, multitasking, and file handling.

 

Q-22. In Linux, what names are assigned to the different serial ports?

Ans. Serial ports are identified as /dev/ttyS0 to /dev/ttyS7.

These are the names equivalent to COM1 to COM8 in Windows.

 

Q-23. What is a zombie process? 

Ans. Zombies are essentially the premature processes whose mature parent processes died without reaping its 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 does have any association with a zombie.

 

Q-24. What makes a process 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.

 

Q-25. How can we see if there are zombie processes on a system?

Ans. An existing zombie process can be determined by running “ps aux” and then looking for a Z in the STAT column.

 

Q-26. How to remove zombie process from a system?

Ans. There are two ways to terminate a zombie.

1. If the parent is alive, then it must call a wait() syscall to clean up a zombie.
2. 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.

 

Q-27. How do you access partitions under Linux? 

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>.

 

Q-27. What is the purpose of ‘hash’ command?

Ans. The “hash” is one of a bash shell’s built-in command. 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.

For Example.

You can delete a particular command from a hash table using -d option, and -r option to reset the complete hash table.

 

Q-28. Explain virtual desktop.

Ans. It serves as an alternate to the action of minimizing and maximizing of different windows that need 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.

 

Q-29. How will you share a program across different virtual desktops under Linux?

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.

 

Q-30. What are hard links in Linux?

Ans. Hard links point directly to the physical file on the disk and not to its pathname.

It means that if the owner renames or moves the original file to a different location, its link won’t break. The reason it does that because it links to the file and not to the path where the file is present.

 

Summary – Essential Linux Questions and Answers for Freshers.

We are hopeful that the above essential Linux questions and answers would 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’d enjoyed the post, then please care to share it with friends and on social media.

Keep Learning,

TechBeamers.

Leave a Reply


*