Top 20 Linux Interview Questions for Freshers

In this article, you will learn top 20 linux interview questions with answers for freshers. Please practice these questions as 90% questions will be asked during in linux admin interview.

Q:1. What are the advantages of open source?

Ans: Open source facilitates you to distribute your software, including source codes freely to anyone who is interested. You can add features and correct the errors of the source code.

Read More: Open Source

Q:2. Is it legal to edit Linux Kernel?

Ans: Yes. You can edit Linux Kernel as it is released under General Public License (GPL) and anyone can edit it. It comes under the category of free and open source software.

Q:3. What is the root account in Linux?

Ans: The root account is a systems administrator account, and has full control of the system.

Q:4. What is the difference between Telnet and SSH?

Ans:  Telnet and SSH both are communication protocol which are used to manage the remote system. SSH is Secured, which requires exchanging of the keys whereas telnet transmits data in plain text, which means telnet is less secure than SSH.

Q: 5. How to extend the logical volume (LVM)?

Ans: Sometimes file system size may be full, so we need to increase the size of the logical volume to continue adding the data in it. The size of the logical volume can be increased online, no downtime required. You can check current size of the logical volume by lvdisplay <LV name> and the size of the file system by df -hT command. You can increase the size of the logical volume by lvextend or lvresize commands. Then finally you can update the file system by resize2fs or xfs_growfs commands.

# df -hT
# lvextend -L +<size in MB></dev/vgname/lvname> or
# lvresize -L +<size in MB></dev/vgname/lvname>
# resize2fs </dev/vgname/lvname>
# lvdisplay </dev/vgname/lvname> (to check the size of the logical volume)
# df -hT (to check the size of the file system)

Q:6. What is inode number?

Ans: Inode numbers are the objects the Linux Operating System used to record the information about the file.

Inode number consists of two parts.

  1. First part contains information about the file, owner, its size and its permissions.
  2. Second part contains pointer to data blocks associated with the file content.

That’s why we use inode number to get the file information quickly.

Q:7. How to create the LVM, make a file system and mount it permanently?

Ans: To create LVM, initially we require one or two physical disks for example /dev/sdb and /dev/sdc. If there is no second disk then make the required partitions using fdisk command and change the partition code as 8e. Firstly, you need to convert the Physical disk into physical volumes. Then you need to create the volume group by using physical volumes. Using volume group you will create logical volume.

After creating LVM, You have to create a file system. Now you will create a mount point to mount the above created LVM file system. You can mount the LVM on the above created mount point temporarily but it is recommended to make it permanently after adding entries into /etc/fstab file.

# pvcreate /dev/sdb /dev/sdc
# vgcreate <Volume group name><physical volume names> or
# vgcreate -s <PE size in MB><Volume group name><physical volume names>
# lvcreate -L +<PE size in MB> -n <Logical Volume Name><Volume group name>
# lvcreate -l <No. of PE> -n <Logical Volume Name><Volume group name>
# mkfs.ext2/ext3/ext4/xfs /dev/<Volume group name>/<Logical Volume Name>
# mkdir /mnt/<Directory Name>
mount /dev/<Volume group name>/<Logical Volume Name> <Mount Point> or
# vim /etc/fstab /dev/<Volume group name>/<Logical Volume Name> /mnt/ defaults 0 0 # mount -a
# df -hT (to see the mounted partitions with file system types)

Q:8. How to reduce or shrink logical volume(LVM)?

Ans: Reducing the size of the logical volume is a complicated task and you have to remember few points before reducing the logical volume, otherwise the file system may be damaged. Logical volume size cannot be reduced on fly and it requires few minutes downtime because we have to unmount the file system.
After unmounting file system we need to check the consistency of the file system. Then you need to update the file system using resize2fs, then after we can reduce or shrink the logical volume. Finally you need to mount the file system.

# umount <file system mount point>

# e2fsck <device or partition name>
# resize2fs </dev/vgname/lvname>
# lvreduce -L -<size in MB> </dev/vgname/lvname>
# lvdisplay </dev/vgname/lvname> (to check the size of the logical volume)
# mount -a (to mount the file system)
# df -hT (to check the size of the file system)

Q:9. What are the locations of the logical volumes and volume groups?

Ans: Below are the default locations of logical volume and volume group.

  •  /etc/lvm/backup        (the logical volumes backup location)
  • /etc/lvm/archive         (the volume groups backup location)

Q:10. How to check whether user is already created or not?

Ans: We can check in different ways whether user is created or not.

id <User Name>                   (It shows the user id, group id and user name if user is already created)

cat /etc/passwd | grep <User Name> (It shows the user's details if user is already created)

Q:11. Explain the sudo user?

Ans: Sudoers allows particular users to run various root user commands without requiring a root password. /etc/sudoers is the configuration file to configure the normal user as privileged user. It is not recommended to open this file using vim editor because this editor cannot check the syntax by default and whatever we typed in that file that will blindly save in this file. So, one editor is especially available to open this file, ie., visudo , normal users cannot execute this command.
Only root user can run this command. If this file is opened nobody can open this file again on another terminal because “The file is busy” message is displayed on the terminal for security reasons.

Q:12. What are permissions available in Linux?

Ans: There are mainly three types of permissions available in Linux as shown below,
read —– r —– 4
write —– w —– 2
Execute —– x —— 1

Permissions File Directory
r Read a file eg. cat <File Name> Read a directory contents eg. ls /dir
w Create, delete or modify the contents of the file, Create, delete or modify files inside a directory,
x Not required for file. It is only required for scripting files. Go to inside the directory eg. # cd /dir

Q:13. What are the default permissions of a file and directory?

Ans: The default permissions of a file = 6 6 6
The default permissions of a directory = 7 7 7

Q:14. What is load average and how to check?

Ans: Load Average is the value which represents the load on your system for a specific period of time. it might be considered the ratio of the number of active tasks to the number of available CPUs.
You can use either top or uptime command to view the output of the load average as shown below.
uptime – 00:07:00 up 4 days, 6:14, 1 user, load average: 0.11, 0.14, 0.09
top – 00:07:12 up 4 days, 6:15, 1 user, load average: 0.09, 0.13, 0.09

Q:15. Can you please explain set uid (suid), set gid (sgid) and sticky bit?

Ans: set uid (suid) : If we plan to allow all the users to execute the root users command then we go for set uid (suid). It can be applied for user level and is applicable for files only.

# chmod u+s               (to set the suid on that file)
# chmod u-s                (to remove the suid from that file)

ls -l (if ‘x’ is replaced with ‘s’ in owner’s level permissions that means suid is applied on that file)

r w s r w x r w x (here ‘s’ is called set uid or suid)

  • # chmod u+s /usr/sbin/init 6         (then any user can restart the system using this command init 6)
  • # chmod u+s /sbin/fdisk                  (then any user can run the fdisk command)
  • # strings                                                (to read the binary language of the command ie., the string command converts the binary language into human readable language)
  • # strings mkfs                                      (to read the mkfs command’s binary language into human readable language)

Normally set uid (suid) permission will be given on scripting files only.

set gid (sgid):
If You want to allow all users of one group to get the group ownership permissions then we go for set gid (sgid).
It can be applied for group level and is applicable on directories only.

# chmod g+s             (to set the sgid on that directory)
# chmod g-s              (to remove the sgid from that directory)

sticky bit:
It protects the data from other users when all users have full permissions on a directory.
It can be applied on others level and applicable for directories only.

# chmod o+t            (to set the sticky bit permission on that directory)
# ls -ld
r w x r w x r w t        (where 't' is called the sticky bit)

Q:16. What is umask in linux?

Ans: The user file-creation mode mask (umask) is used to determine the file permissions for newly created files or directories. You can use umask to control the default file or directory permissions for newly created files or directories. It is a four-digit octal number. The default umask value for normal user is 0002 and the umask value for root user is 0022.

The changed file permissions for normal users = 6 6 6 – 0 0 2 = 6 6 4.
The changed directory permissions for normal users = 7 7 7 – 0 0 2 = 7 7 5.
The changed file permissions for root user = 6 6 6 – 0 2 2 = 6 4 4
The changed directory permissions for root user = 7 7 7 – 0 2 2 = 7 5 5

# umask <Value>          (to change the umask value temporarily)

# vim /etc/bashrc (open this file and change the umask value to effect the whole system)
# source /etc/bashrc (to updated the source file)
# vim .bashrc (open this file in user's home directory and at last type as follows)
(save and exit the file)
# source .bashrc (or logout and login again (to the system to effect that umask value)

Q:17. How to change permissions of a file or directory in linux?

Ans: You can change the permission of a file or directory in linux using chmod command line utility. The numeric representation for permissions are (read = 4, write = 2, execute = 1) and the total value is (4 + 2 + 1) = 7.

  • chmod 774 <File Name or Directory> (to give read, write and execute to owner and read, write and execute to group and read permission to others)
  • chmod 660 <File Name or Directory> (to give read and write to owner and read and write to group and null permission to others)

Q:18. What is the format of the cron job?

Ans: Cron jobs are the scheduling jobs at a particular time, day of the week, week of the month and month of the year. You can use command <crontab -e> to edit or remove cron jobs. The syntax of cron entries is shown below

<minutes>  <hours>  <day of the month>  <month of the year>  <day of the week>  <job or script>
(0 - 59)         (0 - 23)            (1 - 31)                (1 - 12 or jan, feb, …)   (0 - 6 or sun, mon, …)
Options Explanation
* considered as a wild card. Means any possible value.
*/10 considered as every 10 minutes, hours, days or months. Replacing 10 with any numerical value will change this option.
1,3,5 Considered as an OR, so if placed in the hours, this could mean at 1, 3 or 5 o’clock
10-15 considers for any value between 10 and 15. So if placed in day of the month this would be days 10 through 15 or if put in hours, it would be between 10 AM and 3 PM.

Q:19. Explain the booting process in Linux systems?

Ans: Linux systems contains normally 6 stages in booting process.

BIOS > MBR > GRUB > Kernel > Init > Runlevel


BIOS stands for Basic Input and Output System. Whenever we power on the system, the system runs self diagnostic checks and detects all the connected input and out peripherals. This process is called POST (Power On Self Test). It loads the MBR (Master Boot Record) into the memory.


MBR stands for Master Boot Record. It is located in the 1st sector of the bootable disk. The size of the MBR is 512 bytes and it contains three components.
1. Primary boot loader information and its size is 446 bytes.
2. Partition table information and its size is 64 bytes.
3. MBR validation check and its size is 2 bytes. Its main purpose is whether the MBR is valid or not.
The primary boot loader contains GRUB or LILO. MBR loads and executes the GRUB boot loader.


GRUB stands for Grand Unified Boot loader. LILO stands for Linux Loader and is used in old Linux systems. If we have multiple kernel images installed in our system, we can choose which one to be executed. GRUB displays a splash screen, waits for few seconds. If we do not enter anything, it loads the default kernel image as specified in the grub configuration file.

GRUB has the knowledge of the file system (the old LILO didn’t understand the system). GRUB configuration file is /boot/grub/grub.conf (/etc/grub.conf is a link to this) and /boot/grub2/grub.conf is the GRUB configuration file in RHEL – 7. This file contains kernel and initrd(initramfs) images. So, in simple terms GRUB loads and executes kernel and initrd images.


Kernel initialises itself and loads the kernel modules and mounts the root file system as specified in the “root=” in grub.conf and then kernel executes the /sbin/init program. Since init was the 1st program to be executed by Linux kernel, it has the process ID (PID) of 1. Systemd is the initial process in RHEL – 7 and its process ID is 1 in (RHEL 7) We can see this id by # ps -ef | grep init command. initrd stands for initial RAM Disk. initrd is used by kernel as temporary file system until kernel is booted and the real root the file system is mounted.

init level 

In this level, program reads the /etc/inittab file and put the system into specified run level. init identifies the default run level from /etc/inittab file and we can change the this default run level whenever we needed. We can find the default run level by # grep “initdefault” /etc/inittab command on our system. /etc/systemd/system/ file and brings the system into the default run level according to the scripts the processes will start or stop (in RHEL 7).
Normally the default run level in Linux is 3 in CLI (Command Line Interface) mode and 5 in GUI (Graphical User Interface) mode.

Run Level Programs 

The following run levels are available in Linux systems.
0 = halt or shutdown the system
1 = Single user mode
2 = Multi user without NFS
3 = Full multi user mode but no GUI and only CLI mode
4 = Unused
5 = Full multi user mode with GUI (X11 system)
6 = reboot the system

Q:20. How to configure NFS server?

Ans: NFS stands for Network File system and it is a utility to share the local files between machines which are NFS compatible which means you can share the files between Linux and unix machines not between Linux and windows systems. UDP protocol is used in NFS. We can configure NFS using below commands.

Firstly, install the NFS package by below command.

# yum install nfs* -y
Create the NFS shared directory on server system.
# mkdir /public

Modify the permissions of the /public directory by.
# chmod 777 /public

Modify the SELinux context of the /public directory if SELinux is enabled by executing the below command.
# chcon -t public_content_t /public

create few files in shared /public directory.
# touch f{1..10}

Finally, open the file NFS configuration file and put an entry of the NFS shared information.
vim /etc/exports
<Shared Directory Name> <to whom to export the shared directory > (<permission>, sync)

/public (rw, sync)
(to export the /public to server system only)

Common Mount permission options

rw read/write permissions
ro read-only permissions
insecure Allows the use of ports above 1024
sync Specifies that all changes must be written to disk before a command completes
no_wdelay Forces the writing of changes immediately
root_squash Prevents root users

Hence, you have gone through top 20 linux interview questions for freshers. I hope you are feeling confident.

I hope I helped.. Thanks!!

Read Also : Top 10 Shell Scripting Interview Questions with Answers

Share on:

Ravindra Kumar

Hi, This is Ravindra. I am founder of TheCodeCloud. I am AWS Certified Solutions Architect Associate & Certified in Oracle Cloud as well. I am DevOps and Data Science Enthusiast.

Recommended Reading..

4 thoughts on “Top 20 Linux Interview Questions for Freshers”

Leave a Comment