Friends Linux is one of the most popular operating systems used in servers, cloud computing, and even in personal computers. If you are preparing for a Linux-related interview in 2025, it’s important to know the key concepts, commands, and troubleshooting techniques.
In this guide, we have listed the most common Linux Interview Questions 2025 along with simple explanations. Whether you are a beginner or someone looking to refresh your knowledge, these questions will help you feel confident in your interview. Let’s get started!
Contents
- 1 Linux Interview Questions 2025
- 1.1 10 Problem-Solving Linux Interview Questions (2025)
- 1.1.1 1. What is Linux?
- 1.1.2 2. What are the main components of Linux?
- 1.1.3 3. What is the difference between Linux and Unix?
- 1.1.4 4. How do you check the current working directory in Linux?
- 1.1.5 5. How do you list all files in a directory?
- 1.1.6 6. How do you create a new file in Linux?
- 1.1.7 7. How do you move or rename a file?
- 1.1.8 8. How do you delete a file in Linux?
- 1.1.9 9. How do you check system uptime in Linux?
- 1.1.10 10. How do you check disk usage in Linux?
- 1.1.11 11. How do you check the Linux version installed on a system?
- 1.1.12 12. How do you create a new directory in Linux?
- 1.1.13 13. How do you copy a file from one location to another?
- 1.1.14 14. How do you change file permissions in Linux?
- 1.1.15 15. What command is used to check running processes in Linux?
- 1.1.16 16. How do you find a specific word inside a file in Linux?
- 1.1.17 17. How do you schedule a task in Linux?
- 1.1.18 18. How do you switch users in Linux?
- 1.1.19 19. How do you find the IP address of your Linux system?
- 1.1.20 20. How do you stop a process in Linux?
- 1.1.21 21. How do you find the size of a file in Linux?
- 1.1.22 22. How do you check the available memory in Linux?
- 1.1.23 23. How do you change the hostname of a Linux system?
- 1.1.24 24. What is the difference between hard links and soft links in Linux?
- 1.1.25 25. How do you view the contents of a file in Linux?
- 1.1.26 26. How do you find a specific file in Linux?
- 1.1.27 27. How do you check system logs in Linux?
- 1.1.28 28. How do you check the CPU usage in Linux?
- 1.1.29 29. How do you unzip a compressed file in Linux?
- 1.1.30 30. How do you restart a service in Linux?
- 1.1.31 31. Multiple Choice: Which command is used to display the current date and time in Linux?
- 1.1.32 32. One-Word Answer: Which Linux command is used to count words in a file?
- 1.1.33 33. Multiple Choice: What is the default shell in most Linux distributions?
- 1.1.34 34. Short Answer: How do you remove a directory in Linux?
- 1.1.35 35. One-Word Answer: Which command is used to display the manual pages of a command?
- 1.1.36 36. Multiple Choice: Which Linux directory contains system logs?
- 1.1.37 37. Short Answer: How do you check the number of users currently logged in?
- 1.1.38 38. One-Word Answer: Which Linux command is used to compress files?
- 1.1.39 39. Multiple Choice: Which of the following commands is used to shut down a Linux system?
- 1.1.40 40. Short Answer: How do you change the password for a user in Linux?
- 1.2 10 Linux MCQs for Interviews (2025)
- 1.2.1 31. Which command is used to display the current working directory?
- 1.2.2 32. What is the default directory for user home directories in Linux?
- 1.2.3 33. Which command is used to delete a directory along with its contents?
- 1.2.4 34. Which Linux command is used to change file ownership?
- 1.2.5 35. How can you display the contents of a text file one page at a time?
- 1.2.6 36. What does the grep command do?
- 1.2.7 37. Which command is used to see the list of active processes?
- 1.2.8 38. What is the purpose of the df -h command?
- 1.2.9 39. How do you switch to the root user in Linux?
- 1.2.10 40. Which file stores the list of scheduled cron jobs?
- 1.2.11 41. A process is consuming too much CPU. How do you identify and stop it?
- 1.2.12 42. You accidentally deleted an important file. How do you recover it?
- 1.2.13 43. Your disk space is full. How do you find and delete large files?
- 1.2.14 44. How do you check which ports are in use on your Linux system?
- 1.2.15 45. Your server is slow. How do you analyze and fix the issue?
- 1.2.16 46. A scheduled cron job is not running. How do you debug it?
- 1.2.17 47. You need to monitor real-time logs of an application. How do you do it?
- 1.2.18 48. How do you find which user last modified a file?
- 1.2.19 49. You want to block an IP address from accessing your server. How do you do it?
- 1.2.20 50. A Linux system is stuck or unresponsive. How do you troubleshoot?
- 1.1 10 Problem-Solving Linux Interview Questions (2025)
Linux Interview Questions 2025
10 Problem-Solving Linux Interview Questions (2025)
1. What is Linux?
Answer:
Linux is an open-source operating system based on Unix. It is widely used for servers, embedded systems, and cloud computing.
Explanation:
Linux is free to use and highly secure. It allows multiple users and multitasking, making it a popular choice for professionals.
2. What are the main components of Linux?
Answer:
The main components of Linux are:
- Kernel – The core of the OS that manages hardware and processes.
- Shell – The interface that takes user commands.
- File System – Organizes and stores files.
- System Libraries – Help applications interact with the kernel.
Explanation:
Each component plays a role in making Linux work smoothly. The kernel is the most important part, as it controls everything.
3. What is the difference between Linux and Unix?
Answer:
Linux is open-source and free, while Unix is a proprietary OS used mainly in large enterprises.
Explanation:
Linux is inspired by Unix but is more flexible. Many companies prefer Linux because of its cost-effectiveness and strong community support.
4. How do you check the current working directory in Linux?
Answer:
Use the pwd
command.
pwd
Explanation:
This command prints the path of the directory you are currently in, helping you know where you are in the file system.
5. How do you list all files in a directory?
Answer:
Use the ls
command.
ls
Explanation:
By default, ls
shows files in the current directory. You can use options like ls -a
to see hidden files.
6. How do you create a new file in Linux?
Answer:
Use the touch
command.
touch filename.txt
Explanation:
The touch
command creates an empty file if it doesn’t exist. You can also use echo
or nano
to create files.
7. How do you move or rename a file?
Answer:
Use the mv
command.
mv oldname.txt newname.txt
Explanation:
The mv
command is used to rename a file or move it to a different directory.
8. How do you delete a file in Linux?
Answer:
Use the rm
command.
rm filename.txt
Explanation:
Be careful while using rm
because deleted files cannot be recovered easily. To delete a directory, use rm -r directory_name
.
9. How do you check system uptime in Linux?
Answer:
Use the uptime
command.
uptime
Explanation:
This command shows how long the system has been running, along with the current time and system load.
10. How do you check disk usage in Linux?
Answer:
Use the df -h
command.
df -h
Explanation:
This command shows available and used disk space in a human-readable format, making it easy to understand storage usage.
11. How do you check the Linux version installed on a system?
Answer:
Use the following command:
uname -r
or
cat /etc/os-release
Explanation:uname -r
shows the kernel version, while cat /etc/os-release
provides detailed OS information, including the distribution name and version.
12. How do you create a new directory in Linux?
Answer:
Use the mkdir
command.
mkdir new_folder
Explanation:mkdir
stands for “make directory.” It creates a new folder in the current location. You can also create nested directories using mkdir -p parent/child
.
13. How do you copy a file from one location to another?
Answer:
Use the cp
command.
cp file.txt /home/user/
Explanation:
The cp
command copies files from one directory to another. To copy directories, use cp -r directory_name destination/
.
14. How do you change file permissions in Linux?
Answer:
Use the chmod
command.
chmod 755 filename
Explanation:chmod
(change mode) modifies file permissions. In 755
, the numbers represent read (4), write (2), and execute (1) permissions for different user groups.
15. What command is used to check running processes in Linux?
Answer:
Use the ps
or top
command.
ps aux
or
top
Explanation:ps aux
lists all running processes, while top
provides real-time monitoring of CPU and memory usage.
16. How do you find a specific word inside a file in Linux?
Answer:
Use the grep
command.
grep "word" filename.txt
Explanation:grep
searches for a specific word or pattern in a file. It is useful for quickly locating information in large files.
17. How do you schedule a task in Linux?
Answer:
Use the cron
job scheduler by editing the crontab file.
crontab -e
Example cron job to run a script every day at 5 AM:
0 5 * * * /path/to/script.sh
Explanation:
Cron jobs automate tasks like backups, system maintenance, or running scripts at scheduled times.
18. How do you switch users in Linux?
Answer:
Use the su
command.
su username
Explanation:
The su
(substitute user) command allows you to switch to another user account. To switch to the root user, use su - root
.
19. How do you find the IP address of your Linux system?
Answer:
Use the ip
or ifconfig
command.
ip a
or
ifconfig
Explanation:
These commands display network interface details, including the system’s IP address, MAC address, and network status.
20. How do you stop a process in Linux?
Answer:
Use the kill
or pkill
command.
kill PID
or
pkill process_name
Explanation:kill
stops a process using its Process ID (PID). pkill
terminates processes by name. To force kill, use kill -9 PID
.
21. How do you find the size of a file in Linux?
Answer:
Use the ls -lh
or du
command.
ls -lh filename
or
du -h filename
Explanation:ls -lh
shows file size in a human-readable format, while du -h
(disk usage) provides detailed file size information.
22. How do you check the available memory in Linux?
Answer:
Use the free
command.
free -h
Explanation:
The free
command displays total, used, and available memory. The -h
option makes the output more readable by showing sizes in MB or GB.
23. How do you change the hostname of a Linux system?
Answer:
Use the hostnamectl
command.
sudo hostnamectl set-hostname new-hostname
Explanation:
The hostnamectl
command allows you to change the system’s hostname permanently. You may need to restart the system for the changes to take effect.
24. What is the difference between hard links and soft links in Linux?
Answer:
- Hard Link: A duplicate file that shares the same inode.
- Soft Link (Symbolic Link): A shortcut that points to another file.
Example of creating a hard link:
ln original.txt hardlink.txt
Example of creating a soft link:
ln -s original.txt softlink.txt
Explanation:
Hard links remain even if the original file is deleted, while soft links break if the original file is removed.
25. How do you view the contents of a file in Linux?
Answer:
Use the cat
, less
, or more
command.
cat filename.txt
less filename.txt
more filename.txt
Explanation:
cat
prints the entire file at once.less
andmore
allow scrolling through large files.
26. How do you find a specific file in Linux?
Answer:
Use the find
command.
find /path -name "filename"
Explanation:
The find
command searches for files by name, type, or size. To search for all .txt
files, use:
find /path -name "*.txt"
27. How do you check system logs in Linux?
Answer:
Use the journalctl
or cat
command.
journalctl -xe
or
cat /var/log/syslog
Explanation:
System logs help diagnose errors and monitor system activities. journalctl
is used for systemd-based logs, while /var/log/syslog
contains general logs.
28. How do you check the CPU usage in Linux?
Answer:
Use the top
or htop
command.
top
or
htop
Explanation:top
displays real-time CPU and memory usage. htop
(if installed) provides a more user-friendly interface with colors and process management options.
29. How do you unzip a compressed file in Linux?
Answer:
Use the unzip
or tar
command.
unzip file.zip
For .tar.gz
files:
tar -xvzf file.tar.gz
Explanation:unzip
extracts .zip
files, while tar -xvzf
is used for .tar.gz
archives. The options stand for:
x
– Extractv
– Verbose (show progress)z
– Handle.gz
compressionf
– File name follows
30. How do you restart a service in Linux?
Answer:
Use the systemctl restart
command.
sudo systemctl restart service_name
Explanation:
This command restarts system services like Apache (apache2
), MySQL (mysql
), or SSH (ssh
). To check if a service is running, use:
systemctl status service_name
31. Multiple Choice: Which command is used to display the current date and time in Linux?
A) date
B) time
C) clock
D) datetime
Answer: A) date
Explanation:
The date
command prints the system’s current date and time. You can also format it using options like date +"%Y-%m-%d %H:%M:%S"
.
32. One-Word Answer: Which Linux command is used to count words in a file?
Answer: wc
Explanation:
The wc
(word count) command counts the number of words, lines, and characters in a file. Example:
wc -w filename.txt
33. Multiple Choice: What is the default shell in most Linux distributions?
A) bash
B) sh
C) zsh
D) fish
Answer: A) bash
Explanation:
Bash (Bourne Again Shell) is the most commonly used shell in Linux. Other shells like zsh
and fish
provide additional features but are not the default.
34. Short Answer: How do you remove a directory in Linux?
Answer: Use the rm -r
command.
rm -r directory_name
Explanation:rm -r
removes a directory and all its contents. Be careful while using it, as deleted files cannot be easily recovered.
35. One-Word Answer: Which command is used to display the manual pages of a command?
Answer: man
Explanation:
The man
command provides detailed documentation for Linux commands. Example:
man ls
36. Multiple Choice: Which Linux directory contains system logs?
A) /home
B) /var/log
C) /etc/logs
D) /usr/logs
Answer: B) /var/log
Explanation:
The /var/log
directory stores system logs, including authentication logs, kernel logs, and application logs.
37. Short Answer: How do you check the number of users currently logged in?
Answer: Use the who
or w
command.
who
or
w
Explanation:who
shows the logged-in users, while w
provides additional details like system uptime and active processes.
38. One-Word Answer: Which Linux command is used to compress files?
Answer: gzip
Explanation:gzip
compresses files to reduce their size. Example:
gzip file.txt
39. Multiple Choice: Which of the following commands is used to shut down a Linux system?
A) shutdown -h now
B) poweroff
C) halt
D) All of the above
Answer: D) All of the above
Explanation:
All these commands can shut down the system:
shutdown -h now
shuts down immediately.poweroff
turns off the system.halt
stops the system without powering off.
40. Short Answer: How do you change the password for a user in Linux?
Answer: Use the passwd
command.
passwd username
Explanation:
The passwd
command allows users to change their password. Only the root user can change another user’s password.
10 Linux MCQs for Interviews (2025)
31. Which command is used to display the current working directory?
A) pwd
B) ls
C) cd
D) mkdir
Answer: A) pwd
Explanation:
The pwd
(print working directory) command shows the full path of the current directory.
32. What is the default directory for user home directories in Linux?
A) /home
B) /usr
C) /root
D) /etc
Answer: A) /home
Explanation:
The /home
directory stores personal files for regular users, while /root
is for the system administrator.
33. Which command is used to delete a directory along with its contents?
A) rmdir
B) rm -r
C) delete
D) remove
Answer: B) rm -r
Explanation: rm -r
(recursive remove) deletes directories and their files. rmdir
only works on empty directories.
34. Which Linux command is used to change file ownership?
A) chmod
B) chown
C) chgrp
D) mv
Answer: B) chown
Explanation:
The chown
command changes the owner of a file. Example: chown user:group filename
.
35. How can you display the contents of a text file one page at a time?
A) cat
B) less
C) nano
D) touch
Answer: B) less
Explanation: less
allows scrolling through large files, unlike cat
, which prints everything at once.
36. What does the grep
command do?
A) Finds a word in a file
B) Deletes a file
C) Moves a file
D) Copies a file
Answer: A) Finds a word in a file
Explanation:grep "word" filename.txt
searches for specific words or patterns inside a file.
37. Which command is used to see the list of active processes?
A) ps
B) jobs
C) top
D) Both A and C
Answer: D) Both A and C
Explanation: ps
shows a snapshot of processes, while top
provides real-time monitoring of running processes.
38. What is the purpose of the df -h
command?
A) Displays available disk space
B) Finds a file
C) Deletes a directory
D) Shows running services
Answer: A) Displays available disk space
Explanation: df -h
(disk free) shows disk usage in a human-readable format (MB, GB).
39. How do you switch to the root user in Linux?
A) sudo su
B) switch root
C) su root
D) Both A and C
Answer: D) Both A and C
Explanation: su root
switches to root, but sudo su
is preferred for security reasons in some systems.
40. Which file stores the list of scheduled cron jobs?
A) /etc/crontab
B) /var/log/syslog
C) /etc/passwd
D) /home/cron
Answer: A) /etc/crontab
Explanation:
Cron jobs are scheduled tasks, and their settings are stored in /etc/crontab
for system-wide use.
41. A process is consuming too much CPU. How do you identify and stop it?
Solution:
- Identify high CPU usage:
top
orps aux --sort=-%cpu | head -10
- Find the process ID (PID).
- Stop the process:
kill PID
or force stop:kill -9 PID
Explanation:top
and ps
help locate resource-heavy processes. The kill
command is used to terminate them safely.
42. You accidentally deleted an important file. How do you recover it?
Solution:
- Check the Trash folder (for GUI-based Linux).
- Use
ls
to check backups in/var/backups/
. - If deleted from ext3/ext4 file systems, use
extundelete
:sudo extundelete /dev/sdX --restore-file /path/to/file
Explanation:
Recovering files depends on backups or recovery tools. extundelete
works only if the disk space hasn’t been overwritten.
43. Your disk space is full. How do you find and delete large files?
Solution:
- Find large files:
du -ah / | sort -rh | head -10
- Delete unnecessary files:
rm filename
- Clean package cache:
sudo apt autoremove && sudo apt clean
Explanation:du
helps locate large files. apt autoremove
cleans unnecessary packages.
44. How do you check which ports are in use on your Linux system?
Solution:
sudo netstat -tulnp
or
sudo lsof -i -P -n
Explanation:
These commands show active network connections and the services using them. This helps troubleshoot networking issues.
45. Your server is slow. How do you analyze and fix the issue?
Solution:
- Check CPU and RAM usage:
top free -h
- Check disk I/O performance:
iostat -x 1 5
- Restart unnecessary services:
sudo systemctl stop unused_service
Explanation:top
and free
show system performance. iostat
helps analyze disk bottlenecks.
46. A scheduled cron job is not running. How do you debug it?
Solution:
- Check if the cron service is running:
systemctl status cron
- View the user’s cron jobs:
crontab -l
- Check logs for errors:
cat /var/log/syslog | grep CRON
Explanation:
Cron jobs may fail due to syntax errors, permission issues, or a stopped cron service.
47. You need to monitor real-time logs of an application. How do you do it?
Solution:
tail -f /var/log/app.log
Explanation:tail -f
shows the latest log entries as they are written, useful for debugging live applications.
48. How do you find which user last modified a file?
Solution:
ls -ltu filename
or
stat filename
Explanation:ls -ltu
shows files sorted by last access time. stat
gives detailed file metadata, including last modification time.
49. You want to block an IP address from accessing your server. How do you do it?
Solution:
Using iptables
:
sudo iptables -A INPUT -s 192.168.1.100 -j DROP
Explanation:iptables
blocks unwanted IP addresses, preventing unauthorized access.
50. A Linux system is stuck or unresponsive. How do you troubleshoot?
Solution:
- Switch to a different terminal:
Ctrl + Alt + F2
- Check system logs:
journalctl -xe
- Kill unresponsive processes:
kill -9 PID
- Reboot if necessary:
sudo reboot
Explanation:
Switching terminals can help regain control. Logs provide error details, and killing processes may restore functionality without rebooting.