December 3, 2023
50 Top Common Linux Interview Questions for Beginning in 2023

Approximately 90% of the fastest computers in the world run Linux, did you know? There is no question as to why! A favorite among techies, Linux is quick and strong. The best spot for you to be ready for the interview, if you want to become a Linux administrator, is here. I’ll be covering a few of the most significant and frequently asked questions about Linux in interviews in this article.

This Blog Post on Linux Interview Questions is split into two sections: Theoretical Questions in part A and Scenario-based Questions in part B. Let’s get going!

Theoretical Questions In Linux

We will go over the most typical theoretical and concept-based interview questions in this section of the guide.

What is Linux?

A Unix-based operating system called Linux is free and open-source. Linus Torvalds created Linux at the beginning. In order to help people who couldn’t buy expensive operating systems like Windows, iOS, or Unix, Linux was created.

What is the difference between Linux and Unix?

The following list explains the main differences between Linux and UNIX:

What is the difference between Linux and Unix?
Linux vs. Unix – Linux Interview Questions

 What is Linux Kernel? Is it legal to edit Linux Kernel?

System software at the lowest level is referred to as Linux kernel. In addition to serving as a user interface, it is utilised to manage resources.

In fact, editing the Linux kernel is legal. The General Public Licence (GPL) governs the distribution of Linux. Users may change and modify any project that is made available under the GPL.

What is LILO?

Linux LOader is referred to as LILO. A Linux boot loader called LILO loads the Linux operating system into the main memory to start running. Most PCs come with bootloaders for particular Windows or Mac OS versions. Therefore, you must install a unique bootloader for Linux OS before using it. One such bootloader is LILO.

When the computer is turned on, the BIOS runs a few preliminary checks before handing off the command to the Master Boot Record. Following this, LILO launches the Linux OS and loads it.

The benefit of LILO is that it enables quick Linux OS booting.

What are the basic components of Linux?

Linux’s essential components are as follows:

  • The operating system’s central processing unit (kernel), which controls hardware and operations, is a key component.
  • Shell: The command interpreter used by Linux is called shell.
  • Another means by which a user can communicate with the system is through a graphic user interface or GUI. However, the interactional elements of GUI, as opposed to CLI, are Images, Buttons, and TextBoxes.
  • System utilities are the features of the programme that let a user control a computer.
  • Software programmes or a group of features created to carry out a certain task are known as application programmes.

Which are the Shells used in Linux?

In Linux, the most popular shells are:

  • bash: A Second Bourne For most Linux distributions, Shell is the default..
  • slang: Bourne Once more, Shell is the default in most Linux distributions.
  • KSH: Korn. Shell is a high-level programming language.
  • csh: C Shell offers job control, spelling checks, and syntax similar to C.
  • zsh: A variety of unique features of Z Shell include closing comments, login/logout monitoring, closing files, and filename creation.
  • fish: Friendliness and Interactivity Shell has various unique features, such as web-based configuration, auto-suggestions, and fully scriptable with clean scripts.

What is Swap Space?

When there is not enough room in the RAM to accommodate all the programmes that are executing at once, Linux uses swap space, an additional storage area. To enable the CPU to swiftly fetch data, programmes remain in RAM when they are being used. In the event that there are more running programmes than RAM can hold, the Swap Space is where they are kept. Now, the processor will search the Swap Space and RAM for information.

Linux utilises swap space as an addition to RAM.

What is the difference between BASH and DOS?

Sl. no.BASHDOS
1.Commands are case-sensitive.Commands are not case-sensitive.
2.‘/’ (forward slash) is used as a directory separator. (backslash) is used as an escape character.‘/’ (forward slash) is used as command argument delimiter. (backslash) is used as a directory separator.
3.Follows naming convention: 8 characters for file name postfixed with 3 characters for the extension.No naming convention.
        Bash vs Dos – Linux Interview Questions

What command would you use to check how much memory is being used by Linux?

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

Explain file permission in Linux.

  1. Opens and lets the user read the file.
  2. Write: Enables opening and editing of the file by the user.
  3. Allows the file to be run by the user.
The chmod command can be used to modify the permissions of a file or directory. Utilising the chmod command can be done in one of two ways:
  1. Symbolic mode
  2. Absolute mode

Symbolic mode

The following generic syntax can be used to modify permission in symbolic mode:

$ chmod <target>(+/-/=)<permission> <filename>

where <permissions> can be r: read; w: write; x: execute.

<target> can be u : user; g: group; o: other; a: all

'+' is used for adding permission

'-' is used for removing permission

'=' is used for setting the permission

For instance, you might want to determine the permissions so that only users in your group and the user individually may read, write, and execute the document.

Then the command for this will be:

$ chmod u=rwx,g=rx,o=r filename

Absolute mode

In Absolute mode, the following general syntax is used to modify permission:

$ chmod <permission> filename

After octal representation, the Absolute mode is used. The user, user group, and all are represented by the first three digits, starting with the leftmost.

The significance of the digits that can be used and their impact are explained in the table below.

0No permission– – –
1Execute permission– – x
2Write permission– w –
3Execute and write permission: 1 (execute) + 2 (write) = 3– wx
4Read permissionr – –
5Read and execute permission: 4 (read) + 1 (execute) = 5r – x
6Read and write permission: 4 (read) + 2 (write) = 6rw –
7All permissions: 4 (read) + 2 (write) + 1 (execute) = 7rwx

As an illustration, suppose you wish to establish permission so that only users in your group and the user themselves may read, write, and execute it. Everyone else has no right to read it.

So, this will require the command:

$ chmod 754 filename

What are inode and process id?

The operating system’s identifier for each file is called an inode. Similar to that, each process has its own individual identifier, or “process id.”

Which are the Linux Directory Commands?

pwd: shows the location of the active working directory.

Syntax: $ pwd

ls: the working directory’s whole list of files and folders.

Syntax: $ ls

cd: is employed to modify the current working directory.

Syntax: $ cd <path to new directory>

mkdir: Creates a new directory

Syntax: $ mkdir <name (and path if required) of new directory>

rmdir: Deletes a directory

Syntax: $ rmdir <name (and path if required) of directory>

What is Virtual Desktop?

The ability to use the desktop outside of the actual screen’s boundaries is made possible by the virtual desktop functionality. To increase the capabilities of the standard screen, Virtual Desktop essentially creates a virtual screen.

Virtual Desktop implementation is possible in one of two ways:

  1. Switching Desktops
  2. Oversized Desktops

Switching Desktops
Switching Desktops allows you to set up separate virtual desktops on which to execute different applications. Each virtual desktop in this scenario will function as a separate desktop, and the users who are now logged into that desktop are the only ones who can access the programmes that are running on each of these desktops.

Oversized Desktops
The user can move and browse around an oversized desktop that is bigger than the actual screen, but it does not provide a separate virtual desktop.

Which are the different modes of vi editor?

  1. Regular/Command mode: This lets you view the content
  2. Editing and insertion of text is possible in this mode.
  3. Replacement mode: This lets you overwrite content

What are daemons?

A daemon is an application of a program that operates in the background and offers features that the operating system’s core may not offer. Daemons are typically employed to manage services in the background without having direct access to interactive users. The function of daemons is to manage recurring requests and then route them to the proper programs for execution.

What are the process states in Linux?

The steps in the procedure are as follows:

  • The procedure has been developed and is ready to be used.
  • Running: This procedure is being carried out
  • Wait or block: The procedure is awaiting input from the user.
  • Terminated or finished The operating system ended the process when it had finished running.
  • Zombie: Although the process was stopped, the data was still present in the process table.

Explain the grep command.

Global Regular Expression Print is known by its given name Grep. Using regular expression pattern matching, the grep command can be used to search for text within a file.

Syntaxgrep [options] pattern [files]

Example:

$ grep -c "linux" interview.txt

The “interview.txt” file’s word count for the word “Linux” will be displayed by this command.

Explain Process Management System Calls in Linux

  • fork (): Used to create a new process
  • exec(): Execute a new program
  • wait(): Wait until the process finishes execution
  • exit(): Exit from the process

And the System Calls used to get Process ID are:

  • getpid():- get the unique process id of the process
  • getppid():- get the parent process unique id

Explain the ‘ls’ command in Linux

The ls command is used to list the files in a specified directory. The general syntax is:

$ ls <options> <directory>

For example, if you want to list all the files in the Example directory, then the command will be as follows:

$ ls Example/

There are different options that can be used with the ls command. These options give additional information about the file/ folder. For example:

-l lists long format (shows the permissions of the file)
-a lists all files including hidden files
-i lists files with their inode number
-s lists files with their size
-S lists files with their size and sorts the list by file size
-t sorts the listed files by time and date

Explain the redirection operator.

Redirecting the output of one command as an input to another command or file is done using the redirection operator.

This can be applied in two ways:

“>” either creates a new file or overwrites the existing file’s content.

‘>>’ either make a new file or appends the new content to the end of the existing one.

Why is the tar command used?

To extract or make an archived file, use the tar command.

In this example, the command would be:

$ tar -xvzf sample.tar.gz

If, for example, you want to make an archive of every file located at /home/linux/, the command would be:

$ tar -cvzf filename.tar.gz

where c: create archive, x: extract, v: verbose, and f: file

What is a Latch?

The temporary storage unit known as a latch can either store 0 or 1 and is controlled by a timed signal. The primary purpose of a latch is to store state data. A latch has two stable states: high-output or 1, and low-output or 0. When turned on, a latch can store one bit of data.

Describe a Microprocessor.

A Microprocessor is a machine that carries out commands. It is a single-chip device that retrieves, decodes and executes instructions from memory. A microprocessor can do the following three basic tasks:

  • Addition, subtraction, multiplication, and division are examples of mathematical operations.
  • Transfer data between memory locations. Make decisions based on the conditions and jump to fresh, different instructions based on the decision.

Explain Regular Expressions and Grep

To find data with a specific pattern, regular expressions are utilised. Regular Patterns can be used with various commands, including tr, sed, vi, and grep.

.  Match any character
^  Match the beginning of the String
$  Match the end of the String
*  Match zero or more characters
  Represents special characters
?  Match exactly one character

What is the minimum number of disk partitions required to install Linux?

It is necessary to have a minimum of two partitions.

All of the files are kept on one disc, which is utilised as the local file system. Files belonging to the OS, files used by programmes and services, and user-created files are all included in this. Furthermore, the other partition is used as swap space, which functions as extra RAM memory.

Scenario-Based Questions in LINUX

In order to determine how much practical knowledge you have, interviewers will combine scenario-based questions with more theoretical ones. We will go over such questions in this section of the Linux interview questions.

How to copy a file in Linux?

Linux supports copying files with the cp command. Typical syntax is as follows:

$ cp <source> <destination>

Let’s say you wish to move a file called questions.txt from the /new/linux directory to /linux/interview. The command would be:

$ cp questions.txt /new/linux /linux/interview

How to terminate a running process in Linux?

There is a separate process id for each process. We must first identify the process id in order to end it. All currently active processes are listed with their process ids via the ps command. Later, we stop the process by using the kill command.

To list every process, use the following command:

$ ps

Suppose the process id of the process you want to terminate is 3849, then you will have to terminate it like this:

$ kill 3849

How to rename a file in Linux?

Linux does not have a dedicated command for renaming files. However, you rename the file using the copy or move command.

Using the Move command

$ mv <oldname> <newname>

Using the Copy command

$ cp <oldname> <newname>

And then delete the old file.

$ rm <oldname>

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

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

Syntax: $ (command) > (filename)

How to see the list of mounted devices on Linux?

By running the following command:

$ mount -l

How to find where a file is stored in Linux?

You can use the locate command to find the path to the file.

Suppose you want to find the locations of a file name sample.txt, then your command would be:

$ locate sample.txt

How to find the difference in two configuration files?

You can use the diff command for this: 

$ diff abc.conf xyz.conf

Write a bash script to delete all the files in the current directory that contains the word “linux”.

for i in *linux*; do rm $i; done

How would you create a text file without opening it?

The touch command can be used to create a text file without opening it. The touch command will create an empty file. The syntax is as follows:

$ touch <filename>

Suppose you want to create a file named sample.txt, then the command would be:

$ touch sample.txt

How would you delete a directory in Linux?

There are two commands that can be used to delete a directory in Linux.

  • rmdir

$ rmdir <directory name>

  • rm -rf 

$ rm -rf <directory name>

Note: The command rm -rf should be used carefully because it will delete all the data without any warnings. 

How would you schedule a task in Linux?

There are two commands to schedule tasks in Linux: cron and at.

The cron command is used to repeatedly schedule a task at a specific time. The tasks are stored in a cron file and then executed using the cron command. The cron command reads the string from this file and schedules the task. The syntax for the string to enter in the cron file is as follows:

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

Suppose you want to run a command at 4 pm every Sunday, then the string would be:

0 16 * * 0 <command>

The command is used to schedule a task only once at the specified time.

Suppose you want to shut down the system at 6 pm today, then the command for this would be:

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

Suppose you try to delete a file using the rm command and the deletion fails. What could be the possible reason?

  • The path specified to the file or the file name mentioned might be wrong
  • The user trying to delete the file might not have permission to delete the file.

How do you look at the contents of a file named sample. z?

The .z extension means that the file has been compressed. To look at the contents of the compressed file, you can use the zcat command. Example:

$ zcat sample.z

How to copy files to a Floppy Disk safely?

Follow these steps to copy files to a Floppy Disk safely:

  1. Mount the floppy disk
  2. Copy the files
  3. Unmount the floppy disk

If you don’t unmount the floppy disk, then the data might become corrupted. 

How to identify which shell you are using?

Open the terminal and run:

$ echo $SHELL

This will print the name of the Shell being used. 

How can you login to another system in your network from your system?

SSH can be used for this. The Syntax is as follows:

ssh <username>@<ip address>

Suppose you want to login into a system with IP address 192.168.5.5 as a user “mike”, then the command would be:

$ ssh mike@192.168.5.5

How would you open a file in read-only mode using the vim editor?

$ vim -R <filename>

How would you search for a specific Employee ID in a file using the vim editor?

$ vim +/<employee id to be searched> <filename>

How to jump to a particular line in a file using vim editor?

$ vim +<line number> <filename>

How do you sort the entries in a text file in ascending order?

This can be done using the sort command.

$ sort sample.txt

What is the export command used for?

The export command is used to set and reload the environment variables. For example, if you want to set the Java path, then the command would be:

$ export JAVA_HOME = /home/user/Java/bin

How do you check if a particular service in running?

$ service <servicename> status

How do you check the status of all the services?

$ service --status-all

How do you start and stop a service?

To start:

$ service <servicename> start

To stop:

$ service <servicename> start

Explain the free command.

This command is used to display the free, used, swap memory available in the system. 

Typical free command output. The output is displayed in bytes.

$ free

I sincerely hope that these Linux interview questions will enable you to succeed in your interview. And best of luck to you!

Visit Website

Youtube Channel

Contact US

THANKS FOR YOUR PRECIOUS TIME

EPEDAGOGUE GLOBAL PVT LTD

YOUR MENTOR

PRAKASH CHAND THAPLIYAL

Leave a Reply

Your email address will not be published. Required fields are marked *