Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
10 Interview Questions and Answers on Linux Commands
Linux is an open-source operating system that has gained popularity over the years. Linux commands are essential for system administration, development, and daily operations. If you are preparing for a technical interview, understanding core Linux commands is crucial. This article provides 10 common Linux command interview questions with detailed answers to help you succeed.
What is the command to create a new file in Linux?
The command to create a new file in Linux is touch. This versatile command allows users to create empty files instantly.
touch filename.txt
The touch command can also update timestamps of existing files and create multiple files simultaneously:
touch file1.txt file2.txt file3.txt
What is the command to display system information in Linux?
Several commands display system information depending on your specific needs:
| Command | Purpose | Example Output |
|---|---|---|
uname -a |
Kernel and system info | Linux hostname 5.4.0 x86_64 |
lscpu |
CPU information | Architecture: x86_64, CPU(s): 4 |
cat /etc/os-release |
Distribution details | Ubuntu 20.04.3 LTS |
free -h |
Memory usage | Total: 8.0G, Used: 2.1G |
What is the command to display running processes in Linux?
The ps command displays currently running processes. Two commonly used variations are:
ps aux ps -ef
For real-time process monitoring, use top or htop:
top htop
What is the command to display disk space usage?
The df command shows disk space usage for mounted filesystems:
df -h
This displays sizes in human-readable format (GB, MB, KB). Other useful options:
df -TShows filesystem typesdf -iShows inode usagedu -sh /pathShows directory size
What is the command to display memory usage?
The free command shows system memory usage:
free -h
total used free shared buff/cache available
Mem: 7.7G 2.1G 3.2G 256M 2.4G 5.1G
Swap: 2.0G 0B 2.0G
What is the command to display network information?
The modern ip command provides comprehensive network information:
ip addr show ip link show ip route show
Legacy ifconfig command (if available):
ifconfig
What is the command to display the routing table?
Use ip route to view the routing table:
ip route ip route show default
Alternative commands:
route -n netstat -rn
What is the command to display process status?
To check the status of a specific process, use:
ps -p <PID> ps -p 1234
To monitor process status continuously:
watch -n 1 "ps -p <PID>"
What is the command to display the process tree?
The pstree command shows processes in a tree format, displaying parent-child relationships:
pstree pstree -p pstree <PID>
Alternative using ps:
ps -ef --forest
What is the command to check system uptime?
The uptime command displays system uptime, load averages, and logged-in users:
uptime
15:30:25 up 5 days, 2:45, 3 users, load average: 0.15, 0.25, 0.20
For detailed boot information:
who -b last reboot
Conclusion
Mastering these fundamental Linux commands is essential for system administration and technical interviews. Each command offers various options and flags that provide detailed system information. Practice these commands regularly and explore their manual pages using man command_name to deepen your understanding and become proficient in Linux system management.
