Interview Questions Linux

 30 Must Know Linux Command Interview Questions 



1. What is Linux?

Linux is a Unix-based open-source operating system. Linus Torvalds was the first to introduce Linux. The primary goal of Linux was to give a free and low-cost operating system for people who couldn't buy Windows, iOS, or Unix.


2. Define Linux Kernel. Is it legal to edit Linux Kernel?

The Linux Kernel is a low-level software system. It is used to keep track of resources and give a user interface.


Yes, it is legal to edit Linux Kernel. Linux is released under the General Public License (GPL) and any project which is released under GPL can be edited and modified by the end users.


3. What is LILO?

LILO denotes Linux Loader. It is basically a Linux Boot Loader which loads Linux Operating System into a main memory to start execution. Most of the computer systems are featured with boot loaders for certain versions of Mac OS or Windows OS. So if you want to use Linux OS, you have to install a special boot loader for it.


When a computer gets started, BIOS conducts some initial tests and transfers control to the Master Boot Record. From here, LILO loads the Linux OS and starts it. The benefit of utilizing LILO is that it enables a quick boot of the Linux operating system.


4. What are the basic components of Linux?

The following are the basic components of Linux:


Shell: It is a Linux interpreter which is used for executing commands.

Kernel: Kernel is the core part of the operating system which is used to manage hardware and operations.

System Utilities: These are the software functions which help users to manage their computers.

GUI: GUI denotes Graphical User Interface through which the user can interact with the system. But unline CLI, GUI comprises buttons, images and TextBoxes for interaction.

Application Programs: Software programs are designed to complete a particular task.


5. Which shells are used in Linux?

The following are the most common type of Shells used in Linux:


fish: Friendly Interactive Shell offers some special features such as web-based configuration, fully scriptable, and auto suggestions with clean scripts.

bash: Bourne Again Shell is the default for most of the Linux distributions.

zsh: Z Shell offers unique features like startup files, filename generation, login or logout watching, and closing comments.

csh: C Shell follows C like syntax and has features like spelling correction as well as Job Control.


6. What is Swap Space?

Swap Space is the extra space utilized by Linux to temporarily keep concurrently running processes when RAM space is insufficient. When you start a program, it is stored in RAM so that the CPU can quickly retrieve data. If you have more running programs than RAM can accommodate, the Swap Space is used to store these programs. The processor will now search the RAM and Swap Space for data.


Swap Space is used in the form of an extension of RAM by Linux.


7. Differentiate between DOS and BASH.

BASH

DOS

Commands are case sensitive


Commands are not case sensitive


Follows naming convention: 8 characters for file name postfixed with 3 characters for the extension


No naming convention


‘/’ is used in the form of a directory separator.


” is used as an escape character


“/” is used as a command argument delimiter.


” is used in the form of a directory separator.


8. What command would you use to find out how much memory Linux is using?

The following are the commands that you can use:


vmstat

htop

top

free-m


9. What is file permission in Linux?

The following are the three types of permission in Linux:


Read: It allows its users to open and read the file.

Write: It allows its users to open and edit the file.

Execute: It allows its users to run the file.


10. What are inode and process id?

inode is a unique name provided by the operating system for each file. Similarly, the process id is also a unique id provided to each process.


11. What are the Linux Directory Commands?

Given below are the five main Directory Commands in Linux:


pwd: It displays the path of the present working directory.

ls: Lists all the directories and files in the present working directory.

cd: It is used for changing the present working directory.

rmdir: It deletes a directory.

mkdir: It is used to create a new directory.


12. Explain Virtual Desktop.

Virtual Desktop is a feature that allows users to use the desktop beyond the screen's physical constraints. Virtual Desktop, in essence, generates a virtual screen to extend the capabilities of a regular screen. There are two ways in which Virtual Desktop can be implemented:


Oversized Desktops

Switching Desktops

Switching Desktops

In the case of Switching Desktops, you can execute programs on separate virtual desktops. Each virtual desktop will act as a separate desktop, and the apps running on each of these desktops will only be accessible to the individuals who are now using that desktop.


Oversized Desktops

Oversized Desktops don't have a separate virtual desktop, but they do let you pan and scroll around a desktop that's bigger than the physical screen.


13. Name the various modes of vi editors.

Given below are the three modes of vi editors:


Command/ Regular mode: It allows you to view the content.

Edit/ Insertion mode: It allows you to insert or delete content.

Replacement mode: It allows you to overwrite the content.


14. Explain daemons.

A daemon is a computer application that runs in the background to perform functions that aren't available in the standard Operating System. Daemons are typically employed to operate services in the background while avoiding direct interaction with users. Daemons are responsible for handling periodic requests and forwarding them to the proper programs for execution.


15. What are the various process states in Linux?

Given below are the process states in Linux:


Ready: The process is ready to run.

Running: The process has been executed.

Wait or blocked: The process is waiting for the input.

Completed or terminated: The process completed execution or was terminated by the system.

Zombie: The process terminated but the information is still available in the process table.


16. What is the grep command?

Grep denotes Global Regular Expression Print. The grep command is used to search for text in a file using regular expression pattern matching.


Syntax:


grep [options] pattern [files]


17. What are Process Management System Calls?

The following are the System Calls used to manage the process:


fork(): It is used for creating a new process.

exec(): It is used for executing a new program.

wait(): Wait until the process completes the execution.

exit(): It is used to exit from the process.

getpid(): Get the unique process id of the process.

getppid(): Get the parent process unique id.

18. What is the ‘Is’ command in Linux?

The ‘Is’ command is mainly used for listing the files in a particular directory. The general syntax is: 


$ ls <options> <directory>


19. What is the redirection operator?

The redirection operator is used for redirecting the output of a specific command as an input to another command. The following are the two ways of using this:


'>' overwrites the file's existing content or creates a new one.

'>>' adds new content to the end of an existing file or creates a new one.

20. Why is the tar command used?

The tar command is used for extracting or creating an archived file. If you wish to extract all of the files from the sample.tar.gz package, use the following command:


$ tar -xvzf sample.tar.gz


21. Explain a Latch.

A Latch is a temporary storage device that is controlled by a timing signal which can either store 0 or 1. A latch is primarily used to retain state information and has two stable states (high output or 1 and low output or 0). As long as a Latch is powered on, it can store one piece of data.


22. What is a Microprocessor?

A Microprocessor is a device which is used for executing instructions. It is a single-chip device that fetches the instruction from the memory, decodes it, and executes it. The following are the three basic functions which are carried out by a Microprocessor:


Addition, subtraction, multiplication, and division are examples of mathematical operations.

Make decisions based on the circumstances and then jump to new different instructions as needed.

Move data from one position in memory to another.

23. What are Regular Expressions?

Regular Expressions are used to find data with a specific pattern.


24. How to rename a file in Linux?

There is no such particular command for renaming a file in Linux. However, you can use the copy or move command to rename a file.


Move command

$ mv <oldname> <newname>


Copy command

$ cp <oldname> <newname>


Delete command

$ rm <oldname>


25. How to write the output of a command to a file?

You have to use the redirection operator (>) to do this.


Syntax: $ (command) > (filename)


26. How to view the list of mounted devices on Linux?

You can view the list of mounted devices on Linux by running the command given below:


 $ mount -l


27. In Linux, how can we find out where a file is stored?

For this, you can use the locate command.


28. How to copy files to a Floppy Disk?

The following steps will guide you to copy file to a Floppy Disk:


Mount the floppy disk

Copy the files

Unmount the floppy disk


29. How should we identify which shell you are using?

Open the terminal and run:


$ echo $SHELL


30. How would you sort the entries in a text file in ascending order?

You can do this by using the sort command.


$ sort sample.txt