Table of Contents
Linux Interview Questions and Answers
Are you looking for Linux interview questions? Hope you are in the right place to get most of the entry-level interview questions. The below questions are framed for those who are certified or not certified with minimum knowledge in Linux. The explanation for each question will be updated in the future with links referring to each answer.
Go through all the Linux Interview questions to make sure yourself prepared.
The commands that start with the “#” symbol need to be run from a privileged superuser (admin) account. Starting with “$” commands can be run from any unprivileged accounts (Normal users).
Date/Time/Timezone/NTP Management
How will you print the Date & time in Linux?
$ date
2. Which daemon will handle time synchronization in Red Hat Linux 7, Centos 7, Oracle Linux 7?
chronyd
3. How will you set the Date/time on a Red Hat 7/8, CentOS 7, Oracle Linux 7/8?
# timedatectl
4. Protocol / Port number used by NTP?
UDP / 123
5. What command is used to list only the directories?
$ ls -d
6. How to find how long a server running?
$ uptime
Linux Permissions
7. How to change files mode permission in Linux?
# chmod
8. How to change ownership of a file in Linux?
# chown
9. What is SetUID, SetGID?
The setuid is a permission that allows the users to execute a program with the permissions of its owner. The setgid is a permission that allows the user to exec a program with the permissions of the group owner.
10. How to list and change the access control list of a file.
# getfacl file_name
# setfacl file_name
11. Explain what will chmod 640 file_name do?
Provide Read, Write access for the user, Read access for the group, no permission for others.
12. Set GID with any permission for /home/sysadmin/test.txt
# chmod 2774 /home/sysadmin/test.txt
13. What is the default permission for a file when created in Linux.
644
Note: This depends on umask.
Linux File Systems & Partitioning
14. How to create an ext4 filesystem
# mkfs.ext4 /dev/device_name
# mkfs -t ext4 /dev/device_name
15. What is the default file system of RHEL 7, Centos 7, Oracle Linux 7?
# xfs
16. Default home directory of root user will be under which location?
/root
17. How will you partition a disk in Linux?
# fdisk /dev/disk_name
Read more about how to partition using fdisk by clicking on FDISK to partition the disks in Linux
18. How to create a Logical Volume using Physical extends?
# lvcreate -l 43232 -n some_name vg_name
-l will be used to create using extends
For a deep understanding of how Logical volume management works refer to Create Logical volume management LVM file-system in Linux
19. How to remove volume groups from a Linux server?
# vgremove vg_remove
20. What are the steps need to be followed to create a logical volume in Linux?
# fdisk /dev/disk_name # pvcreate /dev/disk_name # vgcreate name /dev/disk_name # lvcreate -n lv_name vg_name
21. Which command is used for creating a swap?
# mkswap /dev/dev_name
22. How will you mount a file system?
# mount /dev/dev_name /mount_point
Read more about Creating and mounting filesystems in Linux
23. Which command will list the UUID of all block devices?
# blkid
24. How to activate and deactivate a swap?
# swapon /dev/device_name # swapoff /dev/device_name
25. How to display total disk usage of the current directory?
$ du -sh
26. How to make a file system persistent during reboot?
Adding entry in FSTAB
27. The maximum number of Primary Partitions can exist on one drive?
4
28. How to list the available mount points in Linux in human-readable format?
# df -hP
29. Which command is used to list the available NFS exports from client machines.
# showmount -e server_IP
User Management
30. How to change the shell of a user?
# chsh -s /bin/bash user_name
31. How to check the aging of a User in Linux
# chage -l user_name
32. How to create a user with UID 5000
# useradd -u 5000 user_name
33. Which command can be used to modify user information?
# usermod
34. How to remove a user from a Linux server?
# userdel user_name
35. Default UID of root user?
0
36. How to print user information’s UID, GID, and Groups?
$ id user_name
37. How to remove a group from Linux servers.
# groupdel group_name
38. How to lock a user password
# passwd -l username
39. In which file, all recently entered commands will be stored?
.bash_history
Linux Networking
40. How to configure IP using TUI/CLI?
# nmtui # nmcli
41. How to bring an interface up or down without restarting or affecting other interfaces?
# ifup ens33
# ifdown ens33
42. How to print the host-name in Linux with short and FQDN format?
# hostname -s
# hostname -f
43. How to set the hostname in RHEL 7 Linux?
# hostnamectl set-hostname some_name_here
44. Which command will print the gateway information in Linux?
# route -n # netstat -nr # ip route
45. The default location of the interface files will be under.
/etc/sysconfig/network-scripts/
46. Which file will show all Services, protocol, and Port numbers in Linux?
$ cat /etc/services
Package & Repository Management
47. What is YUM? Abbreviation of “YUM”?
Yellowdog Update Manager or Modifier
Learn how to use the YUM command for package management by referring to the 31 Yum command for Package Management in Linux
48. How to list all installed packages using the rpm command.
# rpm -qa
49. Which package was used for setting up an Apache webserver
httpd
Service Management
50. How to restart a service in RHEL 7, Oracle Linux 7, Centos 7
# systemctl restart service_name
51. How to completely disable a service from manually starting and at boot time.
# systemctl mask service_name
52. How to get and change the run level in RHEL 7
# systemctl get-default # systemctl set-default run_level
53. Which command was used to change the priority of a process
# renice
Managing Jobs
54. How to run a Job in the background?
some_job &
55. How to bring the background Job to the foreground?
# jobs
Run the command jobs then
# fg job_ID
Linux Signals
56. What will CTRL+C and CTRL+Z do?
CTRL+C Sends a signal to interrupt (SIGINT) the foreground process; CTRL+Z will send a Suspend (SIGTSTP) the foreground process to background.
57. What is the signal number for CTRL+C
2
58. What is the signal number of CTRL+Z
20
Linux Security
59. Which command is used to create an ssh Key?
$ ssh-keygen
60. Full form for TLS?
Transport Layer Security (TLS)
61. How will you check the status of SELinux?
# sestatus
62. How to list the SELinux context of /var/www/html directory.
$ ls -lZ /var/www/html
If you are not good with SELinux it’s time to start right now by visiting How to start using SELinux or Security-Enhanced Linux
63. Command used to secure copy a file over the network.
$ scp
64. How to synchronize two directories securely in Linux?
$ rsync
Listing files | Locating files| Config files
65. How to list all hidden files in a directory?
$ ls -la
66. Which command will print the present working directory?
$ pwd
67. How to complete the command in the terminal by auto-completion?
TAB TAB
68. The default location of the Apache configuration file.
$ ls -lthr /etc/httpd/conf/httpd.conf
Read How to install Apache Web Server on Red Hat Enterprise Linux 7 and Variants for knowing more about Apache.
69. Default document root location of Apache Web server?
/var/www/html
70. How to list the first 25 lines of a file.
$ head -25 filename
71. How to list the last 50 lines of a file.
# tail -50 /var/log/messages # tail -n 50 /var/log/messages
72. How to create a soft link for file /home/linuxsysadmins/linux.txt under /var/www/html/
$ ln -s /home/linuxsysadmins/linux.txt /var/www/html/linux.txt
73. The default location of repository file in RHEL, Centos, Oracle Linux 7?
$ ls -ld /etc/yum.repos.d/
74. Which command is used to determine the path of an executable file?
$ which service_name
75. How to find and list all files owned by user “sysadmin” in his home directory.
# find /home/sysadmin/ -user sysadmin -f type -exec ls -lthr {} \;
76. Under which location wiki pages will be stored?
/usr/share/doc/
77. What will echo “some text” do?
Prints "some text" in screen.
78. How to search for a string starting with sysadmin in the file /etc/passwd?
$ grep "^sysadmin" /etc/passwd
Linux Schedulers
79. How to Schedule and list some tasks for user sysadmin in Linux?
# crontab -u sysadmin # crontab -l -u sysadmin
80. How will you schedule a one-time task in Linux
# at
Linux Archive & Compress
81. Which command is used to archive a file in Linux.
tar
82. The single command used to archive and compress files or directories in Linux?
$ tar zcvf
Linux Boot | Kernel | System Information
83. How to know the kernel version of Linux?
# uname -r
84. What will happen after bootstrapping?
Starting with Init. (0) # RHEL 6.x Starting with Systemd. (1) # RHEL 7.x / 8.x
85. How to print full memory information?
$ cat /proc/meminfo
86. How to print full CPU information?
$ cat /proc/cpuinfo
87. How many run levels are in Linux?
Total 7 run levels, 0-6
88. What is the load average? and explain each section.
5, 10, 15 minutes CPU's are busy.
Linux Editors
89. In vi editor which command sets the number for all lines?
:set nu :set number
90. How to exit vi editors in Linux?
:q!
:wq!
91. Which command will be used to count the total number of lines, words, and characters in a file?
$ wc
SSH Configuration
92. Default port number of SSH?
22
93. How to ssh into a server with IP address 192.168.1.100 using user sysadmin
$ ssh sysadmin@192.168.1.100
Linux Interview Questions on Miscellaneous
94. The maximum allowed characters in a filename in Linux?
255
95. How “anaconda-ks.cfg” will be created under /root ?
Anaconda installer will create “anaconda-ks.cfg” after completing with post installations.
96. The command/package used to create an iSCSI server.
# targetcli
97. What is Samba and why is it used?
Samba used to connect with Windows machines and used as a file-sharing protocol and print service.
98. How to set a variable in shell scripting?
var=uname -a
99. How frequent /tmp gets cleared automatically?
10 days old
100. How to display all currently running processes on any Linux system.
$ ps -ef
Hope this post helps you for preparing your admired Linux admin role. Read all entry-level Linux Interview questions to prepare yourself before appearing in any interview.