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. Below questions are framed for those who certified or not certified with minimum knowledge in Linux. The explanation for each question will be updated in the future with links refer to each answer.
Go through all the Linux Interview questions to make sure yourself prepared.
The commands 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).
How will you print the Date & time in Linux?
2. Which daemon will handle time synchronization in Red Hat Linux 7, Centos 7, Oracle Linux 7?
3. How will you set Date/time on a Red Hat 7/8, CentOS 7, Oracle Linux 7/8?
4. Protocol / Port number used by NTP?
UDP / 123
5. What command used to list only the directories?
$ ls -d
6. How to find how long a server running?
7. How to change files mode permission in Linux?
8. How to change ownership of a file in Linux?
9. What is SetUID, SetGID?
The setuid is a permission which 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.
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?
16. Default home directory of root user will be under which location?
17. How will you partition a disk in Linux?
# fdisk /dev/disk_name
Read more about how to partition using fdisk by click 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 group 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 used for creating swap?
# mkswap /dev/dev_name
22. How will you mount a file-system?
# mount /dev/dev_name /mount_point
Read more about Create and mount filesystems in Linux
23. Which command will list UUID of all block devices?
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?
28. How to list the available mount points in Linux in human-readable format?
# df -hP
29. Which command used to list the available NFS exports from client machines.
# showmount -e server_IP
30. How to change the shell of a user?
# chsh -s /bin/bash user_name
31. How to check the ageing 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?
34. How to remove a user from Linux server?
# userdel user_name
35. Default UID of root user?
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?
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.
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 YUM command for package management by referring to 31 Yum command for Package Management in Linux
48. How to list all installed package using rpm command.
# rpm -qa
49. Which package used for setting up an Apache webserver
Continue reading by clicking on NEXT