100+ Linux Technical Interview Questions:
1. Give any 3 examples of operating systems.
Windows, Linux, and macOS.
2. What is the root home directory?
The root home directory is /root.
3. Your company has terminated a server administrator. What is the first thing as an
administrator you should do to enhance the security?
Change the root password.
4. How to check kernel version?
Use the command uname -a.
5. How to become a root user from a regular user?
Use su - or sudo su to switch to the root user.
6. How to check the computer name or hostname in Linux?
Use the hostname command.
7. List 3 basic commands to navigate the filesystem.
cd, pwd, and ls.
8. How to check network interfaces in Linux?
Use ifconfig, ip addr, or ip a.
9. List 3 different methods of adding a user.
Methods include using useradd, adduser, or manually editing /etc/passwd and
/etc/shadow files.
10. What is the command to create a new user?
useradd username.
11. How to change a user password?
Use the command passwd username.
12. Which directory has all the configuration files?
The /etc directory.
13. List any 4 Linux distributions.
Kali, Red Hat, CentOS, Ubuntu, and SUSE.
14. How to log off from the system?
Use the exit command.
15. How to create a directory?
Use the mkdir command.
16. Explain the purpose of the “touch” command.
touch is used to create an empty file or update the timestamp of an existing file.
17. If a command hangs, how to stop it and get the prompt back?
Press Ctrl + C.
18. Which command is used to count words or lines?
wc.
19. How to rename a file or directory?
Use the mv command.
20. How to change a hostname in Linux?
Edit /etc/hostname and /etc/hosts, then restart the system or use hostnamectl
set-hostname newname.
21. What is the command to change file/directory permissions?
Use chmod.
22. What is the purpose of pipe (|)?
To pass the output of one command as input to another command.
23. What is /etc directory used for?
It contains configuration files for the system.
24. Which command is used to list files in a directory?
ls -l.
25. There is a command which gives you information about other commands, please
explain that command and what is it used for?
man is used to display the manual pages for other commands, providing
detailed information on usage and options.
26. How to delete a file and a directory?
Use rm filename for files and rmdir dirname for directories.
27. What is the difference between “tail” and “tail -10”?
tail displays the last 10 lines of a file by default, while tail -10 explicitly specifies
to display the last 10 lines.
28. List 4 commands to display or read a file’s contents.
cat, more, less, vi.
29. Which command is used to read the top 5 lines of a file?
head -5 filename.
30. What are the different commands or methods to write to a file?
echo > filename, vi filename, cat > filename.
31. What are the different types of shells?
sh, bash, ksh, csh, zsh.
32. Which is the core of the operating system?
Kernel.
33. Which among the following interacts directly with system hardware?
Kernel.
34. List a few commands that are used in troubleshooting network-related issues?
netstat: Displays network connections.
tcpdump: Captures and analyzes network traffic.
ping: Tests connectivity to another host.
traceroute: Traces the route packets take to a network host.
35. How to combine 2 files into 1? E.g., you have 3 lines in file “A” and 5 lines in file
“B”, which command syntax to use that will combine into one file of 3+5 = 8 lines?
cat fileA fileB > combinedfile.
36. What is the echo command used for?
The echo command is used to display a line of text or output a string to the
screen.
37. What does the following command do?
echo "This year the summer will be great" > file1
It creates a new file named “file1” and writes the text “This year the summer will
be great” into it. If the file already exists, it will be overwritten.
38. When you login you get “$” prompt, what is the prompt for root?
The prompt for the root user is typically #.
39. Explain the difference between grep and egrep.
grep is used for basic regular expression pattern matching, while egrep (or grep
-E) supports extended regular expressions, which allow more complex pattern
matching.
40. What is the port number for DNS, NTP, and NFS?
DNS: 53, NTP: 123, NFS: 111 (portmapper) and 2049 (NFS).
41. What is the configuration file name of DNS and where is it located?
The DNS configuration file is named named.conf and is typically located in /etc.
42. How many new directories will be created after running the following command
mkdir {a..c}{1..3}?
9 directories will be created: a1, a2, a3, b1, b2, b3, c1, c2, c3.
43. Your PC is configured with a DNS server address but not the default gateway. Can
the PC access the internet?
No, without a default gateway, the PC cannot access the internet.
44. What is the difference between IP and Gateway?
An IP address is a unique identifier for a device on a network, while a gateway is
a network point that acts as an entrance to another network, often used to
connect local networks to external networks like the internet.
45. Can you assign one static IP to 2 computers, if not then why?
No, assigning the same static IP to two computers will create an IP conflict,
causing network communication issues.
46. How to change IP address to static?
You can change the IP address to static by editing the network configuration
files, such as /etc/network/interfaces on Debian-based systems or
/etc/sysconfig/network-scripts/ifcfg-eth0 on Red Hat-based systems, and
setting the IP address manually.
47. You are trying to ping a server by hostname and you get an error message, “ping:
unknown host …”. What could be the reason and how to solve the problem so you
can ping it by hostname?
The issue could be due to a missing hostname-to-IP mapping in the /etc/hosts
file or an incorrect DNS configuration. Check and update these files to resolve
the issue.
48. Explain the difference between relative and absolute path.
An absolute path starts from the root directory / and specifies the complete
path to a file or directory. A relative path is based on the current directory and
does not start with /.
49. What is the command to change file/directory ownership and group?
Use chown to change ownership and chgrp to change the group.
50. List any 3 types of filesystem.
ext4, NTFS, and FAT.
51. When you login you get a message on the screen. What is the name of that file
and where is it located?
The file is /etc/motd (Message of the Day).
52. What is the /bin directory used for?
The /bin directory contains essential binary executables needed for booting
and system repair.
53. What are the different types of DNS Server?
Master (Primary) and Secondary (Slave) DNS servers.
54. Where are the zone files located for DNS service?
Typically located in /var/named/zonefiles.
55. How many megabytes in 1 gigabyte?
There are 1024 megabytes in 1 gigabyte.
56. What is the purpose of having different network ports?
Different network ports allow multiple applications to communicate over the
network simultaneously without interference.
57. How to display the first column of a file?
Use cat filename | awk '{print $1}' or awk '{print $1}' filename.
58. What is the name of the DNS rpm package?
The package is called bind.
59. What is the difference between nslookup and dig commands?
nslookup is a simple tool for querying DNS servers, while dig provides more
detailed information and is more flexible for DNS troubleshooting.
60. How to check your user id and group id?
Use the id command.
61. What is the difference between “kill” and “kill -9” command?
kill sends a signal to terminate a process gracefully, allowing it to clean up
resources. kill -9 sends a SIGKILL signal, forcing the process to terminate
immediately without cleanup.
62. What is a subnet?
A subnet is a segmented piece of a larger network, designed to improve
performance and security by grouping devices with similar network
requirements.
63. You are troubleshooting an issue with Redhat support and they have asked you
to send the contents of /etc directory. How and which method will you use to
transfer the contents?
Compress the /etc directory using tar and transfer it using ftp or scp.
64. What is syslogd daemon and its purpose?
rsyslogd is a system utility providing support for message logging. It is an
enhanced version of syslogd.
65. What is the command to untar a tarred file?
Use tar -xvf filename.tar.
66. What is the /proc directory used for?
The /proc directory contains virtual files that provide a view into the kernel's
view of the system.
67. What is the purpose of the nsswitch.conf file?
It specifies the sources from which to obtain name-service information in a
range of categories and in what order.
68. Which service/daemon should be running on the server that allows you to
connect remotely?
sshd (SSH Daemon).
69. What is the purpose of a firewall?
A firewall controls incoming and outgoing network traffic based on
predetermined security rules.
70. List any 3 IT components.
Hardware, Operating System, and Applications.
71. Which directory has all the commands we use, e.g., ls, cd, etc.?
/usr/bin or /bin.
72. What is the difference between memory, virtual memory, and cache?
Memory (RAM) is the physical hardware inside a computer that temporarily
stores data.
Virtual memory is a memory management capability that uses disk space as an
extension of RAM.
Cache is a smaller, faster memory component that stores copies of frequently
accessed data for quick access.
73. Correct order of interaction:
a. User >> Operating System >> Hardware.
74. Which of the following is a communication command?
mail.
75. Why is the “tail –f logfilename” command used most often and what does it do?
It outputs all incoming logs in real-time, useful for monitoring log files as they
are updated.
76. How to sort a file in reverse order?
Use sort -r filename.
77. List all byte sizes from smallest to largest.
Bit, Byte, Kilobyte (KB), Megabyte (MB), Gigabyte (GB), Terabyte (TB), Petabyte
(PB), Exabyte (EB).
78. How to check the total number of partitions in Linux?
Use fdisk -l.
79. How to access a Linux system from a Linux system?
Use ssh.
80. Explain the procedure of bonding 2 NICs or interfaces together.
Use network bonding to combine two or more NICs into a single bonded
interface for redundancy or increased throughput. This typically involves
configuring /etc/network/interfaces or /etc/sysconfig/network-scripts/ifcfg-
bond0 and using the bonding kernel module.
81. What is the exact command syntax to list the 5th column of a file and cut the first
3 letters?
awk '{print $5}' filename | cut -c1-3.
82. What is the /etc/hosts file used for?
It is used to resolve hostnames to IP addresses locally.
83. List any 3 options of ‘df’ command and what they are used for.
-h: human-readable format, -i: inodes information, -T: file system type.
84. What is swap space and how to check swap space?
Swap space is a portion of the hard drive used as an extension of RAM. Check
swap space using swapon -s or free.
85. What is inode and how to find an inode of a file?
An inode is a data structure on a filesystem that stores information about a file
or directory. Use ls -i filename to find the inode number.
86. Which file to edit for kernel tuning?
Edit /etc/sysctl.conf for kernel parameter tuning.
87. What is the latest version of Redhat?
Search online for the most recent version as it frequently updates.
88. Name the command to find a specific word from a file.
grep word filename.
89. You have scheduled a job using crontab but it does not run at the time you
specified, what could be the reason and how would you troubleshoot?
Check system time, crontab entry syntax, and /var/log/cron for errors.
90. How to check system hardware information?
Use dmidecode.
91. How to check network interface MAC address?
Use ifconfig or ip link.
92. If I don’t want others to read my file1, how do I do that?
Remove read permission for others using chmod o-r file1.
93. What is the purpose of “uniq” and “sed” commands?
uniq removes duplicate lines from sorted input, sed is a stream editor for
filtering and transforming text.
94. Which command is used to list the contents of a directory in the most recent
time and in reverse order, meaning the most updated file should be listed on the
bottom?
ls -ltr.
95. What is the difference between tar, gzip, and gunzip?
tar is used for archiving files, gzip compresses files, and gunzip decompresses
files.
96. What are the different ways to install an OS?
Using a DVD, DVD ISO, or network boot.
97. How to view the difference between two files?
Use diff file1 file2.
98. You noticed that one of the Linux servers has no disk space left, how would you
troubleshoot that issue?
If using LVM, add more disk space and extend the logical volume. If not, add a
new disk, create a partition, and link it to an existing filesystem.
99. How to check Redhat version release?
Use cat /etc/redhat-release or uname -a.
100. What is the difference between TCP and UDP?
- TCP is connection-oriented and reliable, while UDP is connectionless and
faster but less reliable.
101. What is a zombie process?
- A zombie process is a process that has completed execution but still has an
entry in the process table, waiting for the parent process to read its exit status.
102. How do you search for a pattern/word in a file and then replace it in an entire
file?
- Use sed for search and replace operations.
103. How to check the number of users logged in?
- Use who command.
104. What is the command to view the calendar of 2024?
- cal 2024.
105. Which command is used to view disk space?
- df -h.
106. How to create a new group in Linux?
- groupadd groupname.
107. What is the command to send a message to everyone who is logged into the
system?
- Use wall command.
108. Which command is used to check the total number of disks?
- fdisk -l.
109. What is a mail server record in DNS?
- MX (Mail Exchange) record.
110. What does the following command line do? ps -ef | awk '{print $1}' | sort | uniq
- Lists the first column of all running processes, sorts them, and removes
duplicates.
111. You get a call that when a user goes to www.yourwebsite.com it fails and gets an
error, how do you troubleshoot?
- Check user internet connectivity, DNS configuration, server status, and web
service availability.
112. List 4 different directories in /?
- /etc, /bin, /tmp, /home.