May 14, 2021

Software Mile.com

Latest Software News and Hacks

Top 80 Linux Interview Questions and Answers in 2021

Top 80 Linux Interview Questions and Answers in 2021

Linux is an open-source OS (operating system). An operating system is a software that directly manages the system’s hardware and its resources, such as  CPU, memory, and storage. The OS sits between the applications and the hardware, and it makes the connections between all of the software and its physical resources to do the work.

So if you are looking for Linux Interview Questions and Answers then you are on the right page. We have listed the most frequently asked Interview Questions and Answers. Please go through the entire article so that you will not miss any of the questions.

Top Linux Interview Questions and Answers

1. Differentiate between UNIX and LINUX?

UNIX LINUX
It was developed by AT&T Bell Labs and is not open source. It is open-source and is developed by the Linux community of developers.
Unix is a licensed OS. LINUX is free to use.
The file systems that are supported are fs, gpfs, hfs, hfs+, ufs, xfs, zfs. The file systems that are supported are Ext2, Ext3, Ext4, Jfs, ReiserFS, Xfs, Btrfs, FAT, FAT32, NTFS.
It is mostly used on servers, workstations, or PCs. It is used in wide varieties from desktop, smartphones to mainframes. 
Example: SunOS,SCO UNIX, AIX, HP/UX, ULTRIX, Solaris etc Examples: Ubuntu, GNU, Arch Linux, Debian, etc.

2. What is Linux?

Linux can be defined as an Open-Source Operating System that is based on Unix. It was first introduced by Linus Torvalds. The main purpose of Linux is to provide free and low-cost Operating Systems for users who couldn’t afford Operating Systems like Windows or Unix, or iOS.

3. Define Linux Kernel?

The Linux Kernel is the important component of the Linux operating system (OS) and is the core interface between the computer’s hardware and its processes. It communicates between the two, manages the resources as efficiently as possible.

4. Define Bash?

Bash is a sh-compatible command language interpreter that can execute the commands that are read from the standard input or from the file. It also incorporates useful features from the C and Korn shells.

5. What is LILO?

Linux Loader (LILO ) is a boot loader (a small program that is used to manage a dual boot) for use with the Linux operating system. The new computers are carried with boot loaders for a few versions of Microsoft Windows or the Mac OS. If a computer has to be used with Linux, a special boot loader should be installed. LILO is one of the most popular boot loaders among the users who employ Linux as their main operating system.

6. Can you edit Linux Kernel legally?

Yes. We can edit the Linux Kernel because it is released under the General Public License (GPL), and anyone can edit it. It is free and open-source software.

7. What is the advantage of using an open-source?

One of the main advantages of open-source technologies like Linux is the wide range of options that are available to the users and its increased security. With Linux being open-source, several distributions are available to end-users.

8. Name the basic components of Linux?

The basic components of Linux are given below:

  1. Kernel: It is a core component of the OS that manages operations and hardware.
  2. Shell: It is a Linux interpreter used to execute commands.
  3. GUI: GUI means Graphical User Interface, which is a way for a user to interact with the system. But unlike CLI, GUI comprises Images, Buttons, TextBoxes for the interaction.
  4. System Utilities: These are software functions that allow us to manage the computer.
  5. Application Programs: Software programs or a set of functions that are designed to accomplish a specific task.

9. List some advantages of Linux?

A few of the advantages of Linux are listed below:

  1. Stability and efficiency
  2. Low configuration requirements
  3. Free or small fee: Linux is based on GPL, i.e., General Public License; anyone can use or modify original code for free.
  4. Strong support: A huge number of Linux enthusiasts will exchange their discussions and share some good software, with a very open use atmosphere.
  5. Security: Linux has considerable community support, so it quickly finds system vulnerabilities and quickly releases security patches.

10. Define swap space?

We use Swap space in Linux when the amount of physical memory, i.e., RAM, is full. If the system requires more memory resources and the given RAM is full, the inactive pages in the memory are moved to swap space. Swap space helps machines with a small amount of RAM. 

Linux Interview Questions

11. Name the Shells used in Linux?

The shell types used in Linux are:

  1. bash: Bourne Again Shell is a default shell for most of the Linux distributions
  2. ksh: Korn Shell is the high-level programming language shell.
  3. csh: C Shell follows the C-like syntax, and it provides spelling corrections and Job Control.
  4. zsh: Z Shell provides a few unique features like filename generation, login/logout watching, startup files, closing comments, etc.
  5. fish: Friendly Interactive Shell provides special features such as web-based configuration, fully scriptable with clean scripts.

12. Define shell in Linux?

A Shell provides an interface to the Unix system. It gathers input from the user and executes the programs based on the given input. When a program finishes its execution, it displays the program’s output. Shell is an environment in which the user can run our commands, shell scripts, and programs.

13. Can a Linux system have multiple desktop environments installed?

You won’t face any problems by installing multiple desktop environments. Nothing in the system can stop you from installing KDE, Unity, Enlightenment, GNOME,  and all the others at once (except for disk space). But, desktop environments will “argue” with each other and overwrite the settings.

14. Differentiate between BASH and DOS?

BASH DOS
BASH commands are case-sensitive. DOS commands are not case-sensitive.
The  / character is a directory separator. The acts as an escape character. The  / serves as a command argument delimiter. The is the directory separator.
It follows the Naming convention in files; that is, an eight-character file name is followed by a dot and three characters for an extension. BASH follows no such convention.

Top Linux Interview Questions and Answers

15. Name the Linux which is designed by Sun Microsystems?

Solaris is the Linux of Sun Microsystems.

16. Explain the importance of the GNU project?

GNU is an OS(operating system) that is free software.

Its main goal is to give the computer users their freedom and control in their use of their computers and the computing devices by combinedly developing and publishing the software that gives each and every one the rights to freely run a software, copy it and distribute it, and modify it, study it  GNU software grants these rights in the license.

17. Name the commands that are used to check how much memory is being used by Linux?

You have to use the following commands mentioned below:

  1. free -m
  2. vmstat
  3. top
  4. htop

18. Name the command used to rename a file that is saved?

The command used to rename a file that is saved is “mv.”

19. Define the root account?

The root is mainly a user name or an account that, by default, has access to all the commands and files on a Linux or other Unix-like OS. It is also called the root account, superuser, and root user.

20. Explain different file permission in Linux?

The different file permission in Linux are listed below:

  1. Read: This permission allows the user to open and read files.
  2. Write: It allows the user to open and modify the files.
  3. Execute: It allows the user to run files.

Linux Interview Questions

21. Define internal command?

Internal commands are the commands that are built into the shell. For all the built-in shell commands, execution is fast such that the shell doesn’t search the given path for them in a PATH variable, and also, no process is needed to be spawned for executing it.

 Examples: source, cd, fg, etc.

22. What is CLI?

The CLI (Command Line Interface) is a non-graphical, text-based interface to a computer system, where the user types in the command, and then the computer executes it successfully. The Terminal is a platform or the IDE that provides the command-line interface environment to the user.

23. Define inode and process id?

The index node (inode ) is defined as a data structure in the Unix-style file system that specifies a file-system object like a file or a directory. Each inode here stores disk block locations and attributes of the object’s data. 

In Linux, each process is assigned a process ID or the PID. This is how the operating system can identify and keeps track of all the processes. The first process spawned at boot, known as init, is given a PID of “1”. pgrep init 1. This process is now responsible for spawning another process on the system.

24. Name the command that is used to execute an instruction at the specified time?

The ‘at’ command is used.

25. What is GUI?

Top 80 Linux Interview Questions and Answers in 2021

An interface will allow the user to interact with the system visually through the icons, graphics, and windows is a GUI. If the kernel is the heart of Linux, then the face of the OS is the graphical environment that is provided by the X Window System or X.

26.  Name the Linux Directory Commands?

Directory Commands are the basic commands that help us to navigate the file system.

Directory Command Description
pwd This command stands for print working directory. It mainly displays the current working location or directory of the user.
Is This command shows the list of a folder. It lists out all the files in the directed folder.
cd This command stands for change directory. It is used to change to the directory you want to work from the current directory.
mkdir This command lets us create our own directory.
rmdir It is used to remove a directory from the system.

27. Can you name some Linux Commands?

Some of the Linux commands are listed below:

  1. Curl: It is used to test applications endpoint or connectivity to the upstream service endpoint.
  2. Is: It is used to list the files in the directory.
  3. Tail: It displays the last part of a file.
  4. Cat: It concatenates and prints files.
  5. Grep: It searches file patterns.
  6. Ps: Used to investigate process id.
  7. Env: It allows to set or print the environment variables.
  8. Top: Displays and updates sorted process information.
  9. Netstat: This shows the network status.

28. How can we open a command prompt when issuing a command?

To open the default shell, press Ctrl-Alt-F1. This will provides a command-line interface (CLI) from which you can run commands as you want.

29. What is Virtual Desktop?

Virtual desktops can be defined as a  preconfigured images of the operating systems and applications where the desktop environment is separated from physical devices that are used to access it. Users usually access their virtual desktops remotely over a given network. 

We have  two ways to implement the Virtual Desktop, namely,

  1. Switching Desktops: here, we can create discrete virtual desktops to run programs. Each virtual desktop behaves like an individual desktop, and the programs that are running on each of these desktops are accessible only to the users that are using that particular desktop. 
  2. Oversized Desktops:  They do not offer a discrete virtual desktop, but they will allow the user to scroll and pan around the desktop, which is larger in size than that of the physical screen. 

30. Name the popular office suite that is available free for both Microsoft and Linux?

Open Office Suite

Linux Interview Questions

31. Name the commands used to Check Memory Use in Linux?

Commands to Check Memory Use in Linux are:

  1. cat command to show the Linux Memory Information.
  2. free command is mainly used to  Display the Amount of Physical and Swap Memory.
  3. vmstat command is used to Report Virtual Memory Statistics.
  4. The top command is used to Check Memory Use.
  5. htop command is used to Find the Memory Load of Each Process.

32. Mention the different modes of vi editor? 

different modes of vi editor

The default editor that comes with the Linux OS is called visual editor(vi).

We have three modes:

  1. Regular Command mode: It lets us view the content
  2. Insertion or edit mode: it lets us delete or insert content
  3. Replacement mode:  It lets us overwrite content

33. What is SMTP?

Simple Mail Transfer Protocol(SMTP) is defined as an application used to send, receive, and relay the outgoing emails between the senders and receivers. When you send an email, it is transferred over the internet from one server to another server using SMTP. 

34. What is a preferred size for a swap partition under a Linux system?

The preferred size for the swap partition is double the amount of physical memory available on systems. If this isn’t possible, then the minimum size should be the same as that of the amount of memory installed.

35. What are daemons? 

daemons

A daemon can be defined as a long-running background process that answers the requests for the services. The term is originated with Unix, but most OS use daemons in some form or another.

Top Linux Interview Questions and Answers

36. Define Samba and its uses?

Samba is a useful networking tool for anyone who has Windows and Linux systems on their network. Running on a Linux system allows Windows to share the files and printers on the Linux host, and it also allows Linux users to access resources shared that are by Windows systems.

37. What are symbolic links in Linux?

A symlink is also known as a symbolic link, is a file type in Linux that points to another folder or file on your computer. Symlinks are similar to that of the shortcuts in Windows. 

38. Define the process states in Linux? 

In Linux operating systems, processes can be in one of the following states mentioned below:

  1. RUNNING & RUNNABLE: Whenever the CPU executes the process, it will be in the  RUNNING state. When the processes are not waiting for any of the resources and are ready to get executed by the CPU, then they will be in the RUNNABLE state.
RUNNABLE state
  1. INTERRRUPTABLE_SLEEP: When a process is in this state, it wakes up from the middle of sleep and processes the new signals sent to it.
  2. UNINTERRUPTABLE_SLEEP: When a process is in this state, it is not going to wake up from the middle of sleep even the new signals are sent to it.
  3. STOPPED: This state defines that the process has been suspended from proceeding further.
  4. ZOMBIE: The process will terminate when the ‘system exit’ API is called or when someone else kills the process.

39. Name the basic commands for user management?

The basic commands are:

  1. last,
  2. chage,
  3. chsh,
  4. lsof,
  5. chown,
  6. chmod,
  7. useradd,
  8. userdel,
  9. newusers etc.

40. Will the Ctrl+Alt+Del key combination work on Linux?

Yes, it does work. Just like Windows, we use this key combination to perform the system restart. But the difference is that we won’t be getting any confirmation message, and therefore, a reboot is necessary.

Linux Interview Questions

41. Explain the grep command?

Grep is defined as a Linux command-line tool that is used to search for a string of characters in a described file. The text search pattern is known as a regular expression. When it finds the match, it prints the line with the corresponding result. The grep command comes in handy when searching through large log files.

Syntax: grep [options] pattern [files]

42. What would be the maximum length for a filename in Linux?

The maximum length for a filename in Linux is 255 characters.

43. How should we refer to the parallel port where devices like printers are connected?

  1. In Windows, we refer to the parallel port as the LPT port.
  2. In Linux, we refer to it as /dev/lp. LPT1, LPT2 and LPT3 would be referred to as /dev/lp0, /dev/lp1, or /dev/lp2 under Linux.

44. Explain the Process Management System Calls in Linux?

Process management makes use of certain system calls:

1. To create a new process, we use fork ().

2. To run a new program, we use exec ().

3. To make the process wait, the wait ()call is used.

4. To terminate the process, we use exit ().

5. To find the unique process id –we use getpid ().

6. To find the parent process id, we use getppid ().

7. To bias the currently running process property, we use nice ().

45.  Is Linux Operating system free from viruses?

No, there is no operating system to date that is virus-free, but Linux is known to have fewer viruses.

Top Linux Interview Questions and Answers

46 Do the hard drive and floppy drives represented drive letters?

No. In Linux, each device and drives have various designations. For example, floppy drives are mentioned as /dev/fd0 and /dev/fd1. IDE/EIDE The hard drives are referred  /dev/hda, /dev/hdb, /dev/hdc.

47. Define the redirection operator?

Redirection is one of the features in Linux when executing a command; it lets us change the standard input/output devices. The basic workflow of any Linux command is it takes an input and gives an output. The standard input device is the keyboard. The standard output device is the screen.

The redirection operator redirects the output of a particular command as an input to another command.

  1. The ‘>’ operator overwrites the existing content of the file, or it creates a new file.
  2. ‘>>’ appends a new content to the end of files, or it creates a new file. 

48. In Linux, name the partition that stores system configuration files?

/stc partition

49. How to change directory permissions under Linux?

  1. chmod +rwx filename to add the permissions.
  2. chmod -rwx directory name to remove the permissions.
  3. chmod +x filename to allow executable the permissions.
  4. chmod -wx filename to take out write and execute permissions.

50. What is the use of the tar command?

The tar command is used to split a collection of files and directories into highly compressed archive files, commonly called tarball or tar in Linux. The tar is the most widely used command to create compressed archive files.

Example: $ tar -xvzf sample1.tar.gz

Linux Interview Questions

51.Name the command used to uncompress gzip files?

The gunzip command is used to uncompress the gzip files.

52. How to access partitions under Linux?

Linux assigns the numbers at the end of each drive identifier. For example, if the first IDE hard drives have three primary partitions, then they would be as named/numbered, /dev/hda1, /dev/hda2, and /dev/hda3.

Commands such as fdisk, sfdisk, and cfdisk are the general partitioning tools that can display the partition information and also modify them.

53. What is a Latch in Linux?

A Latch is defined as a temporary storage device that is controlled by a timing signal which is either store 0 or 1. A Latch usually has two stable states, i.e., high-output or 1, and low-output or 0, and is used to store the state information. A Latch stores one bit of data as long as it is powered on. 

54. Differentiate between soft and hard mounting points?

Soft Mount Hard Mount
It is used for network file protocols like NFS or CIFS. It is generally used to block resources like a local disk or SAN.
If a client fails to connect to the server, it gives an error report and closes the connection. When the client fails to access the server, the connection hangs.

55. What are hard links?

A hard link is an additional name for the existing file on Linux. A  hard link can be defined as a directory entry that is associated with a file name on a file system. All the directory-based file systems should have at least one hard link giving an original name for each file. 

56. What is a Microprocessor?

A microprocessor can be defined as a computer processor where it includes the data processing logic and control on a single integrated circuit or on a small number of integrated circuits.

A Microprocessor can carry out three basic functions:

  1. Mathematical operations like addition, multiplication, division, and subtraction.
  2. Microprocessor moves data from one memory location to another memory location.
  3. It makes decisions based on conditions and jumps to new different instructions based on the decision. 

57. Name the file permissions in Linux? 

We have three types of permissions in Linux OS:

  1. Read: The user can read the file and list the directory.
  2. Write: The user can write new files in the directory.
  3. Execute: The user can access and run the file in a directory.

58. In Linux, what are the filenames that are preceded by a dot?

The filenames that are preceded by the dot are called hidden files. These files are configuration files that hold important data or the setup information. By setting these files as hidden makes them less likely to be deleted accidentally.

59. Define Regular Expressions?

A regular expression in Linux can be defined as a string used to describe several sequences of characters. Regular expressions are used by different Linux commands, including ed, sed, awk, grep.

The most common symbols used in Regular Expressions are:

^ –  Match the beginning of the String

$-  Match the end of the String

*- Match zero or more characters

? –  Match exactly one character

60. Name the commands used to exit from vi editors?

The following given commands are used to exit from vi editors.

  1. :wq command saves the current work and exits from the VI.
  2. :q! command exits from the VI without saving current work.

Linux Interview Questions

61. How can one share a program across various virtual desktops under Linux?

To share a program across various virtual desktops, in the upper left-hand corner of the program window, now look for the icon that looks like the pushpin. Clicking this button will “pin” the application in place, makes it appear in all the virtual desktops, in the same position onscreen.

62. How many disk partitions required to install Linux?

A minimum of 2 partitions required.

63. What does an empty directory represent?

This empty directory name serves as a nameless base for a Linux file system. It serves as an attachment for all other directories, drives, files, and devices.

64. Command to copy a file in Linux?

We mainly use the cp command to copy a file in Linux. The syntax is:

$ cp <source> <destination>

65. Command to delete information from a file in vi?

The following commands delete information from vi editors.

  1. x deletes a current character.
  2. dd deletes the current line.

66. Define the pwd command?

The print working directory (pwd command)  writes the full pathname of the current working directory to standard output.

67. How do you terminate a running process in Linux?

Each and every process has a unique process id. To terminate the process, we need to find the process id. 

The ps command lists all the running processes along with their process id. 

Then we make use of the kill command to terminate the process.

68. Command to create a new file or modify an existing file in vi?

vi filename 

69. Does case-sensitivity affect the way you use commands?

The commands are considered the same only if every character is encoded as it is, including the lowercase and the uppercase letters. This indicates that CD, Cd, and cd are three different commands. Entering a command by using the uppercase letters, where it should have been in lowercase, will produce different outputs.

70. How can we write the output of a command to a file?

We use the redirection operator (>) to do this.

Syntax: $ (command) > (filename)

Linux Interview Questions and Answers

71. What are environmental variables?

In Linux, environment variables are defined as a set of dynamic named values that are stored within the system and are used by applications launched in shells or subshells. Environment variables allow us to customize how the behavior of the application system works.

72. Can you use shortcuts for a long path name?

The answer is Yes. A feature called filename expansion allows you to do this using the TAB key.

73. What are the contents of /usr/local?

It contains locally installed files. 

74. How to insert comments in the command line prompt?

Comments are usually created by typing the “ #” symbol before the actual comment text. This tells a shell to completely ignore what follows after it. 

75. Define command grouping?

Bash mainly provides two ways to group a list of commands to be executed as a unit.

  1. By placing a list of commands between the parentheses causes a subshell environment to be created.

Example: ( list )

  1. By placing a list of commands between the curly braces causes the list to execute in the current shell context.

Example: { list; }

76. Name the command that will display all .txt files, including their individual permission?

The command used to display all .txt files is ls -al *.txt

77. Write down the command that will look for files with an extension “c” and has the occurrence of the string “cat” in it?

Find ./ -name “*.c” | xargs grep –i “cat”

78.Write down the command to calculate the size of a folder?

 Command du –sh folder1.

79. How to attach one file to another in Linux?

To attach one file to another in Linux, we make use of the command cat file2 >> file 1. The operator >>is used to append the output of the named file, or it creates the file if it is not created. While the other command cat file 1 file 2 > file 3 appends two or more files to one.

80. How to schedule a task in Linux?

We have two commands to schedule tasks in Linux, namely, cron and at.

We use the cron command to repeatedly schedule a task at a specific time. The tasks here are stored in the cron file, and then they are executed using the cron command. The cron command usually reads the string from this file and schedules the tasks accordingly. 

The syntax:

<minute> <hour> <day> <month> <weekday> <command>

The at command is mainly used to schedule the task only once at the given time.

For example, if you want to shut down the system at 7 pm today, then the command f would be:

$ echo "shutdown now" | at -m 20:00

Good luck with your Linux Interview, and we hope our Linux Interview Questions are of some help to you. You can also check our PL/SQL Interview Questions which might be of some help to you.

Recommended Articles


Go to Source of this post
Author Of this post: Abdul Rahim
Title Of post: Top 80 Linux Interview Questions and Answers in 2021
Author Link: {authorlink}