Linux is an open-source Unix-like operating system-based family on the Linux kernel, and the OS kernel was first published on 17 September 1991 by Linus Torvalds. Typically, Linux is packaged as the Linux distribution, which contains the supporting libraries and system software and kernel, several of which are offered by the GNU Project. Several Linux distributions use the term “Linux” in the title, but the Free Software Foundation uses the “GNU/Linux” title to focus on the necessity of GNU software, causing a few controversies.

Famous Linux distributions are Ubuntu, Fedora Linux, and Debian, the latter of which is composed of several different modifications and distributions, including Xubuntu and Lubuntu. Commercial distributions are SUSE Linux Enterprise and Red Hat Enterprise Linux. Desktop distributions of Linux are windowing systems like Wayland or X11 and desktop environments like KDE Plasma and GNOME.

Dive into a comprehensive compilation of Linux Commands Interview Questions & Answers, designed to sharpen your command-line proficiency. Whether you’re a Linux enthusiast, a system administrator, or preparing for a technical interview, this resource covers a diverse array of command-line topics. Explore essential commands, shell scripting, file manipulation, and system administration tasks through detailed answers that provide in-depth insights.

Linux Commands Interview Questions

Chown command: The command “chown” stands for change file owner and Group. This command is used to change the ownership of one or more files or folders for a specified user or group. 


$ chown [OPTION]… [OWNER][:[GROUP]] FILE…

$ chown [OPTION]… –reference=RFILE FILE…


cp command: cp command is used to copy files and directories. It is also used to backup files or directories.


$ cp filename

rm command: The rm command is used to remove the directory or file specified on the command line. You need to be careful while removing any file or directory.


rm filename— 



rm filename

Removes single file.

rm filename1, filename2, filename 3

Removes multiple files.

 rm * .pdf

Removes all pdf files in the current directory. 

 rm -i filename(s)

-i mean to confirm before deleting the file

 rm -f filename(s)

Removes files without prompting

rm -fv *.txt

Remove all .txt files in the current directory without prompting

mkdir, command allows users to create directories in Linux. Users can create multiple directories at once and can set the permissions to the directories.


mkdir [options...] [directories ...]




name of the directory to be created

-m=mode, –mode=mode

to set a file mode (permissions, etc.) for the created directories

-p, –parents

create parent directories

–v, –verbose

Verbose output. Print a message for the created directory.

–Z= context, –context=context

If you are using SELinux, this option sets the security context of each created directory to context.


shows help message and exit


It shows version information and exit

The rmdir is used to remove each directory specified on the command line. 


rmdir [-p] [-v | –verbose] [–ignore-fail-on-non-empty] directories


We can use two commands to exit from the vi editor. They are

  • Wqwq command saves the current work and exits from the vi editor.
  • q!: q! The command does not save the current work, but it exits from the vi editor.

The following commands are used to delete information from a file in vi editors.

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

File content commands

  1. head: Display top lines of the file.
  2. tail: Display the last lines of the file.
  3. cat: Concatenate more than 2 files.
  4. more: Displays the content in pager form to view in the terminal. 

It is one of the basic commands in Linux. It is used to list all the files and directories in the file system.zom



We can use it without passing the arguments, then it will list all the files in the current working directory. Files will be displayed in alphabetical order. 


To list the specific directory files use the directory name in the syntax, follow as shown in the below syntax.

ls /etc

We can also pass multiple directories names in the syntax, but separated by space. 

ls /etc /var /etc/passwd



The Tail command print the last N number of lines of the given data, it prints 10 lines by default. 


tail [OPTION]... [FILE]


$ cat names.txt
sql server
linux administration
Now, check the syntax without giving any option or input.
$ tail state.txt

grep command is a filter that is used to the global search for regular expressions.


grep [options] pattern [files]


The ps command displays the current process status of the system. And it displays the processes id’s with some other related data also. 


Ps [options]


[root@rhe17~]# ps


12330 pts/0 00:00:00 bash

21621 pts/0 00:00:00 ps


Linux ping (Packet Internet Groper) command is a command that is used to check connection status between source and destination. In simple words, this command is used to check whether a network is available and if the host is reachable. It can also be used to troubleshoot different connectivity issues, verify connectivity at an IP -level to a second TCP/IP device, and name resolution. One can use this command to test both the computer name and IP address of the computer. 

The command used to check the default run level is “/etc/inittab”. 


The command used to check the size of the file or directory is “du”. Here “du” stands for disk usage that is used to check information of disk usage of files and directories on a machine. It is also used to display files and directory sizes in a recursive manner. 

$ du -sh /var/log/*
1.8M /var/log/anaconda
384K /var/log/audit
4.0K /var/log/boot.log
0 /var/log/chrony
4.0K /var/log/cron
4.0K /var/log/maillog
64K /var/log/messages 

The command that is used to count the number of characters in a file in Linux is “wc”. Here “wc” stands for word count. It is used to count the number of lines, words, and characters in a text file. 

Grep (Global regular expression print) is a command that is used to the global search for a string of characters in a specified file. The text search pattern is generally known as a regular expression. It simply makes use of pattern-based searching.  

Syntax: grep [options] pattern [files] 
Example: $ grep -c “linux” interview.txt   

The above command will usually print the total count of the word “Linux” in the file “interview.txt”. 

“env” command is basically a shell command that is used to print a list of current environmental variables. Here, “env” stands for the environment. It can also run another process in another environment without any modification of the current environment. It allows you to run programs in a modified environment. It is generally used by shell scripts to launch the correct interpreter. It can also be useful for checking if wrong environment variables prevent the application from starting during troubleshooting.  




“pwd” command is basically a command that is used to print the complete path of the current working directory starting from the root (/). Here, “pwd” stands for Print Working Directory. It is considered one of the most basic and most used commands in Linux. This command is usually a built-in shell command and is also available in different shells such as bash, ksh, zsh, bourne shell, etc.

The command used mostly to check memory status in Linux is “free”. Other commands that can be used are given below: 

  • “cat” command:It can be used to show or display Linux memory information. (cat/proc/meminfo)
  • “vmstat” command:It can be used to report statistics of virtual memory. 
  • “top” command:It can be used to check the usage of memory. 
  • “htop” command:It can be used to find the memory load of each process. 

In Linux, a pipe is basically a form of redirection that is used to send the output of one command to another command for further processing. It simply takes the output from one command and uses it as an input for another. It provides asynchronous execution of commands with help of buffered I/O routines. 

There are basically five Linux directory commands that are used to work with files and directories as given below: 

  • pwd: It stands for “print working directory”. This command is generally used to display the path of the present or current working directory. 
    Syntax:$ pwd 
  • cd: It stands for “change directory”. This command is generally used to change the present working directory to the directory that we want to work on. 
    Syntax:$ cd <path to new directory> 
  • Is: It stands for “list”. This command is generally used to show the full list of content of files and directories in the present working directory. 
    Syntax:$ ls 
  • mkdir:It stands for “make directory”. This command generally allows users to create directories in Linux.  
    Syntax: $ mkdir <name (and path if required) of new directory> 
  • rmdir:It stands for “remove directory”. This command is used to remove/delete each directory that is specified on the command line. 
    Syntax: $ rmdir <name (and path if required) of directory> 

Umask, also known as user file-creation mask, is a Linux command that allows you to set up default permissions for new files and folders that you create. In Linux OS, umask command is used to set default file and folder permission. It is also used by other commands in Linux like mkdir, tee, touch, etc. that create files and directories. 

Syntax: umask [-p] [-S] [mask]  

[mask]: It represents the permission masks that you are applying. 
[-S]: It displays the current mask as a symbolic value. 
[-p]: It displays the current mask along with umask command thus allowing it to be copied and pasted as a future input.  

The command that is used to review boot messages is the “dmesg” command.

env is a shell command is used to print a list of current environmental variables and it can run another process in another environment without any modification of the current environment. 

env [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]




-i, –ignore-environment

Start with an empty environment.

-0, –null

output line End with a 0 (null) byte rather than a newline.

-u, –unset=NAME

removes variable NAME from the environment


Display a help message and exit.

The top command is used to show the system process and it displays and updates the sorted process information. 

netstat command gives various information about the network and routing tables, interface statics and more about the system.

lsof means List of files, we can know which file is opened by which process.



This command is used to change the permission of files and directories. It’s an important command so, I’ll explain it briefly. Therefore, on the whole, there are three ty0pe of permission, read, write and execute and are represented by numbers as shown below.

  1. 4 – read permission
  2. 2 – write permission
  3. 1- execute permission


$ chmod options permissions file name  

$ chmod [OPTION]... MODE[,MODE]... FILE...

$ chmod [OPTION]... OCTAL-MODE FILE...

$ chmod [OPTION]... --reference=RFILE FILE…


In Linux cat command concatenates and prints files. Users might issue cat to check the contents of your dependencies file or to confirm the version of the application that you have already built locally.

cat Example:

$ cat requirements.txt


Users can use the df command to troubleshoot disk space issues. Here df stands for display free disk space.

df Command Example:

df -h

du command in Linux is used to retrieve more detailed information about which files use the disk space in a directory.

du Command Example:

$ du -sh /var/log/*
1.8M /var/log/anaconda
384K /var/log/audit
4.0K /var/log/boot.log
0 /var/log/chrony
4.0K /var/log/cron
4.0K /var/log/maillog
64K /var/log/messages


Categorized in: