Top Linux Command-Based Interview Questions [2025]
Master top Linux command-based interview questions for 2025 with this guide featuring 100+ questions for freshers 2025 and experienced professionals 2025 in DevOps 2025 roles. Covering system monitoring, file management, process management, networking, security, and automation, it equips candidates with Linux command line skills for real-time Linux scenario-based challenges in technical interviews.
![Top Linux Command-Based Interview Questions [2025]](https://www.devopstraininginstitute.com/blog/uploads/images/202509/image_870x_68b966445a576.jpg)
Linux Administration Commands
1. What command would you use to check disk usage on a Linux server?
df -h
- Displays disk space
- Identifies full partitions
Thedf
command shows disk usage in a human-readable format. It helps admins identify storage issues, a core skill for maintaining Linux servers in production environments with large datasets.
2. How would you use a command to monitor real-time CPU usage?
To monitor CPU usage in real-time, use top
or htop
to display process details. This tracks system performance, a vital task for admins ensuring efficient Linux server operations under heavy workloads.
3. Why would you use systemctl
to manage services on a Linux server?
- Controls service states
- Enables/disables services
- Checks status
Thesystemctl
command manages services for reliable system operations.
It replaces olderinit
scripts.
This ensures consistent service management in modern Linux environments.
4. When would you use dmesg
to troubleshoot a Linux server?
The dmesg
command is used to view kernel logs for hardware or driver issues.
- Filters with
dmesg | grep error
- Monitors real-time with
dmesg -w
- Aids diagnostics, a core Linux principle
5. Where would you check system logs using a command on a Linux server?
sudo journalctl -xe
Use journalctl -xe
to view detailed system logs. This identifies errors, a critical task for admins troubleshooting Linux servers in enterprise environments with complex applications.
6. Which command displays running processes on a Linux server?
The ps
command with options like aux
lists running processes with details.
It shows CPU and memory usage.
Admins use it to monitor system activity.
This ensures efficient resource management in production systems.
7. What command would you use to check memory usage on a Linux server?
free -m
- Shows memory stats
- Tracks usage trends
Thefree
command displays memory usage in megabytes.
It helps identify leaks.
This is vital for maintaining Linux server performance.
8. How would you use a command to update packages on a Linux server?
sudo apt update && sudo apt upgrade -y
Run apt update
and apt upgrade
to refresh and install package updates. This ensures security and stability, a core task for admins managing Linux servers in production.
9. Why would you use uptime
to check Linux server performance?
- Shows system uptime
- Displays load averages
- Indicates performance
Theuptime
command reveals system load and runtime. Checking it helps admins assess performance, a critical skill for maintaining stable Linux servers under heavy workloads.
10. When would you use who
to monitor user activity on a Linux server?
The who
command is used to list logged-in users and their sessions.
- Shows login details
- Monitors with
who -a
- Enhances security, a core Linux principle
11. Where would you use a command to check disk I/O performance?
- Use
iostat -x
- Monitors disk metrics
- Identifies bottlenecks
Theiostat
command tracks disk I/O performance.
This is vital for optimizing storage in Linux servers.
Admins rely on it to prevent slowdowns in production systems.
12. Which command restarts a Linux service without downtime?
sudo systemctl reload nginx
Use systemctl reload
to refresh a service like Nginx without stopping it. This maintains uptime, a critical task for admins managing Linux servers in high-availability environments.
13. What command would you use to check system boot time?
The systemd-analyze
command shows boot time details for performance analysis.
- Use
systemd-analyze time
- Check bottlenecks with
systemd-analyze blame
- Optimizes startup, a core Linux task
This ensures efficient server initialization in production.
14. How would you use a command to configure a new user on a Linux server?
sudo adduser newuser
sudo usermod -aG sudo newuser
Run adduser
to create a user and usermod
to grant sudo privileges. This sets up secure access, a core task for admins managing Linux servers in enterprise environments.
15. Why would you use lscpu
to assess Linux server hardware?
- Displays CPU details
- Shows core count
- Identifies architecture
Thelscpu
command provides CPU information.
It aids hardware assessment.
This ensures optimal resource allocation in Linux systems.
16. When would you use lsblk
to manage storage on a Linux server?
The lsblk
command lists block devices for storage management.
- Shows disk hierarchy
- Identifies mount points
- Enhances storage planning, a core Linux principle
This supports efficient disk usage in enterprise environments.
17. Where would you use a command to check filesystem health?
sudo fsck /dev/sda1
Use fsck
to scan and repair filesystem errors. This ensures data integrity, a vital task for admins maintaining Linux servers in production environments with critical data.
18. Which command checks kernel version on a Linux server?
uname -r
- Displays kernel release
- Verifies compatibility
Theuname
command shows the kernel version.
This is critical for ensuring software compatibility.
Admins use it to maintain stable Linux systems.
Scripting Commands
19. What command would you use to debug a Bash script on a Linux server?
The bash -x
command traces script execution for debugging.
- Identifies logic errors
- Logs output with
set -x
- Ensures reliable scripts, a core Linux principle
This prevents automation failures in production environments.
20. How would you use a command to automate log cleanup on a Linux server?
sudo find /var/log -type f -name "*.log" -mtime +7 -delete
Use find
to delete logs older than seven days. This prevents disk issues, a core task for admins automating Linux server maintenance in production systems.
21. Why would you use awk
to process log files on a Linux server?
- Parses text fields
- Filters log data
- Generates reports
Theawk
command processes logs efficiently.
It extracts specific data.
This aids admins in analyzing Linux server performance.
22. When would you use sed
to modify configuration files?
The sed
command edits files non-interactively for automation.
- Replaces text with
sed s/old/new/
- Backups with
-i.bak
- Streamlines configs, a core Linux principle
23. Where would you use a command to schedule a recurring task?
- Use
crontab -e
- Schedules tasks
- Automates jobs
Thecrontab
command sets up recurring tasks.
This ensures automated maintenance.
Admins rely on it for consistent Linux operations.
24. Which command validates a Bash script syntax on a Linux server?
bash -n script.sh
Use bash -n
to check script syntax without execution. This prevents errors, a critical task for ensuring reliable automation in Linux production environments.
25. What command would you use to find large files on a Linux server?
The find
command with size filters locates large files for cleanup.
- Use
find / -size +100M
- Lists large files
- Frees disk space, a core Linux task
This maintains storage efficiency in production systems.
26. How would you use a command to monitor disk space in a script?
df -h | awk '$5 > 80 {print $6 " is at " $5}'
Use df
with awk
to alert on high disk usage. This automates monitoring, a core task for admins maintaining Linux servers in enterprise environments.
27. Why would you use grep
to analyze logs on a Linux server?
- Filters log entries
- Searches patterns
- Speeds analysis
Thegrep
command extracts relevant log data.
It simplifies troubleshooting.
This is vital for diagnosing Linux server issues.
28. When would you use cut
to process text on a Linux server?
The cut
command extracts specific columns from files or output.
- Uses
cut -d',' -f1
for delimiters - Processes structured data
- Enhances automation, a core Linux principle
29. Where would you use a command to automate user account cleanup?
- Use
userdel
- Removes inactive users
- Frees resources
Theuserdel
command deletes unused accounts.
This maintains security.
Admins use it to streamline Linux system management.
30. Which command checks script execution time on a Linux server?
time ./script.sh
Use time
to measure script execution duration. This optimizes performance, a critical task for admins ensuring efficient automation in Linux production environments.
31. What command would you use to parse JSON data in a Linux script?
The jq
command processes JSON data for automation scripts.
- Filters with
jq '.key'
- Parses complex JSON
- Enhances scripting, a core Linux task
This supports API integration in Linux systems.
32. How would you use a command to automate backup creation?
tar -czf /backup/data_$(date +%F).tar.gz /data
Use tar
to create compressed backups with timestamps. This ensures data safety, a core task for admins managing Linux servers in production environments.
33. Why would you use xargs
in a Linux script?
- Processes input streams
- Executes commands
- Handles large datasets
Thexargs
command enhances script efficiency.
It manages bulk operations.
This is critical for automating Linux tasks.
34. When would you use tee
in a Linux script?
The tee
command writes output to files and stdout simultaneously.
- Uses
tee file.log
- Logs script output
- Ensures auditing, a core Linux principle
35. Where would you use a command to monitor script errors?
- Use
tail -f
- Tracks log files
- Identifies errors
Thetail
command monitors script logs in real-time.
This aids debugging.
Admins rely on it for reliable Linux automation.
36. Which command schedules a one-time task on a Linux server?
echo "backup.sh" | at midnight
Use at
to schedule a one-time task. This automates temporary jobs, a critical task for admins managing Linux servers in production environments.
Networking Commands
37. What command would you use to check open ports on a Linux server?
The ss
command lists open ports for network services.
- Uses
ss -tuln
- Shows listening sockets
- Enhances security, a core Linux task
This identifies vulnerabilities in Linux networks.
38. How would you use a command to test network connectivity?
ping -c 4 google.com
Use ping
to test connectivity to a host. This verifies network reachability, a core task for admins troubleshooting Linux servers in enterprise environments.
39. Why would you use netstat
to monitor network connections?
- Shows active connections
- Displays ports
- Tracks traffic
Thenetstat
command monitors network activity.
It aids troubleshooting.
This is vital for maintaining Linux network performance.
40. When would you use traceroute
to diagnose network issues?
The traceroute
command traces packet paths to identify routing issues.
- Uses
traceroute host
- Pinpoints delays
- Enhances diagnostics, a core networking principle
41. Where would you use a command to configure network interfaces?
- Use
nmcli
- Manages interfaces
- Applies settings
Thenmcli
command configures network interfaces.
This ensures connectivity.
Admins rely on it for Linux network management.
42. Which command captures network packets on a Linux server?
sudo tcpdump -i eth0
Use tcpdump
to capture network packets. This analyzes traffic, a critical task for admins troubleshooting Linux network issues in production environments.
43. What command would you use to check DNS resolution on a Linux server?
The dig
command queries DNS for hostname resolution.
- Uses
dig example.com
- Shows response times
- Verifies DNS, a core Linux task
This ensures reliable network connectivity in Linux systems.
44. How would you use a command to monitor bandwidth usage?
sudo iftop -i eth0
Use iftop
to monitor real-time bandwidth usage. This identifies network bottlenecks, a core task for admins managing Linux servers in high-traffic environments.
45. Why would you use ip
to manage network settings on a Linux server?
- Configures interfaces
- Manages routes
- Sets addresses
Theip
command replaces older tools likeifconfig
.
It streamlines network management.
This is critical for Linux network administration.
46. When would you use nslookup
for DNS troubleshooting?
The nslookup
command queries DNS servers for troubleshooting.
- Uses
nslookup host
- Verifies records
- Enhances diagnostics, a core networking principle
47. Where would you use a command to check routing tables?
- Use
ip route
- Shows routing info
- Verifies paths
Theip route
command displays routing tables.
This ensures correct traffic flow.
Admins use it for Linux network stability.
48. Which command tests network latency on a Linux server?
ping -i 0.1 google.com
Use ping
with interval options to measure latency. This assesses network performance, a critical task for admins managing Linux servers in enterprise networks.
49. What command would you use to restart a network service?
The systemctl
command restarts network services for connectivity.
- Uses
systemctl restart networking
- Applies changes
- Ensures uptime, a core Linux task
This restores network functionality in Linux systems.
50. How would you use a command to configure a static IP?
sudo nmcli con mod eth0 ipv4.addresses 192.168.1.100/24
sudo nmcli con up eth0
Use nmcli
to set a static IP and activate the connection. This ensures stable networking, a core task for admins managing Linux servers.
51. Why would you use iftop
to monitor network traffic?
- Shows bandwidth usage
- Tracks connections
- Identifies bottlenecks
Theiftop
command monitors real-time traffic.
It aids network optimization.
This is vital for Linux server performance.
52. When would you use route
to manage routing on a Linux server?
The route
command manages routing tables for network traffic.
- Adds routes with
route add
- Deletes with
route del
- Enhances connectivity, a core networking principle
53. Where would you use a command to check firewall rules?
sudo iptables -L -v
Use iptables -L
to list firewall rules. This verifies network security, a critical task for admins managing Linux servers in production environments.
54. Which command monitors SSH connections on a Linux server?
The ss
command with filters shows active SSH connections.
- Uses
ss -tnp | grep ssh
- Tracks sessions
- Enhances security, a core Linux task
This monitors remote access in Linux systems.
Security Commands
55. What command would you use to check user login attempts?
last
- Shows login history
- Detects unauthorized access
Thelast
command tracks user logins.
It aids security auditing.
This is vital for protecting Linux servers.
56. How would you use a command to secure SSH access on a Linux server?
sudo nano /etc/ssh/sshd_config
# Set: PermitRootLogin no
sudo systemctl restart sshd
Edit sshd_config
to disable root login and restart SSH. This enhances security, a core task for admins managing Linux servers in enterprise environments.
57. Why would you use auditctl
to monitor system events?
- Tracks file access
- Logs system calls
- Ensures compliance
Theauditctl
command monitors system activity.
It supports security audits.
This is critical for Linux server compliance.
58. When would you use fail2ban
to protect a Linux server?
The fail2ban
command blocks brute-force attacks on services like SSH.
- Configures jails in
/etc/fail2ban
- Monitors logs
- Enhances security, a core Linux principle
59. Where would you use a command to check open ports for vulnerabilities?
- Use
nmap localhost
- Scans open ports
- Identifies risks
Thenmap
command audits network security.
This is vital for protecting Linux servers.
Admins rely on it for vulnerability assessment.
60. Which command checks SELinux status on a Linux server?
getenforce
# or
sestatus
Use getenforce
or sestatus
to verify SELinux enforcement. This ensures security, a critical task for admins managing Linux servers in high-security environments.
61. What command would you use to scan for malware on a Linux server?
The clamscan
command scans for malware to secure systems.
- Uses
clamscan -r /
- Logs infections
- Protects data, a core Linux task
This ensures Linux server integrity in production.
62. How would you use a command to restrict file permissions?
sudo chmod 600 /etc/securefile
sudo chown root:root /etc/securefile
Use chmod
and chown
to restrict file access. This secures sensitive data, a core task for admins managing Linux servers in enterprise environments.
63. Why would you use chage
to manage user passwords?
- Sets password expiry
- Enforces policies
- Enhances security
Thechage
command manages password aging.
It ensures compliance.
This is vital for Linux server security.
64. When would you use iptables
to configure firewall rules?
The iptables
command sets firewall rules to secure network traffic.
- Uses
iptables -A INPUT
- Saves with
iptables-save
- Protects services, a core Linux principle
65. Where would you use a command to monitor security logs?
- Use
tail -f /var/log/auth.log
- Tracks login attempts
- Detects breaches
Thetail
command monitors security logs.
This is critical for Linux server protection.
Admins use it to detect unauthorized access.
66. Which command locks a user account on a Linux server?
sudo passwd -l user
Use passwd -l
to lock a user account. This prevents unauthorized access, a critical task for admins securing Linux servers in enterprise environments.
67. What command would you use to check file integrity on a Linux server?
The md5sum
command verifies file integrity against checksums.
- Uses
md5sum file
- Compares hashes
- Ensures authenticity, a core Linux task
This detects tampering in Linux systems.
68. How would you use a command to configure AppArmor profiles?
sudo aa-genprof /usr/bin/app
sudo aa-enforce /etc/apparmor.d/*
Use aa-genprof
to create and aa-enforce
to apply AppArmor profiles. This restricts applications, a core task for admins securing Linux servers.
69. Why would you use pam_tally2
to manage login attempts?
- Tracks login failures
- Locks accounts
- Prevents brute-force
Thepam_tally2
command secures authentication.
It enforces login policies.
This is vital for Linux server security.
70. When would you use ufw
to manage firewall settings?
The ufw
command simplifies firewall configuration for security.
- Enables with
ufw enable
- Configures with
ufw allow
- Enhances protection, a core Linux principle
71. Where would you use a command to audit user permissions?
- Use
getfacl
- Shows file ACLs
- Verifies access
Thegetfacl
command audits permissions.
This ensures secure access control.
Admins rely on it for Linux security.
72. Which command generates SSH keys on a Linux server?
ssh-keygen -t rsa -b 4096
Use ssh-keygen
to create secure SSH keys. This enables safe remote access, a critical task for admins managing Linux servers in distributed environments.
Troubleshooting Commands
73. What command would you use to diagnose a Linux server crash?
The dmesg
command with error filters identifies crash causes.
- Uses
dmesg | grep error
- Analyzes kernel logs
- Restores stability, a core Linux task
This diagnoses issues in production systems.
74. How would you use a command to troubleshoot network connectivity?
ping -c 4 8.8.8.8
traceroute 8.8.8.8
Use ping
and traceroute
to test connectivity and trace routes. This identifies network issues, a core task for admins troubleshooting Linux servers.
75. Why would you use strace
to debug a Linux application?
- Traces system calls
- Identifies errors
- Logs interactions
Thestrace
command debugs application issues.
It pinpoints failures.
This is vital for Linux troubleshooting.
76. When would you use journalctl
to troubleshoot a Linux server?
The journalctl
command analyzes systemd logs for system issues.
- Filters with
journalctl -u
- Monitors with
journalctl -f
- Enhances diagnostics, a core Linux principle
77. Where would you use a command to check disk errors?
- Use
smartctl -a /dev/sda
- Shows disk health
- Detects failures
Thesmartctl
command monitors disk health.
This prevents data loss.
Admins use it for Linux reliability.
78. Which command monitors process resource usage on a Linux server?
top -R
Use top -R
to monitor process CPU and memory usage. This identifies bottlenecks, a critical task for admins troubleshooting Linux servers in production.
79. What command would you use to find a hung process on a Linux server?
The ps
command with state filters finds hung processes.
- Uses
ps -aux | grep D
- Identifies blocked tasks
- Restores performance, a core Linux task
This resolves system slowdowns in production.
80. How would you use a command to check network latency?
ping -i 0.1 -c 10 google.com
Use ping
with interval options to measure network latency. This assesses performance, a core task for admins managing Linux servers in enterprise networks.
81. Why would you use lsof
to troubleshoot file access issues?
- Lists open files
- Shows process IDs
- Identifies conflicts
Thelsof
command tracks file usage.
It aids troubleshooting.
This is vital for Linux system stability.
82. When would you use perf
to analyze Linux performance?
The perf
command profiles CPU and memory for optimization.
- Records with
perf record
- Analyzes with
perf report
- Enhances diagnostics, a core Linux principle
83. Where would you use a command to check kernel module issues?
- Use
lsmod
- Lists loaded modules
- Verifies functionality
Thelsmod
command checks kernel modules.
This ensures system stability.
Admins rely on it for Linux troubleshooting.
84. Which command restarts a hung service on a Linux server?
sudo systemctl restart nginx
Use systemctl restart
to restart a hung service like Nginx. This restores functionality, a critical task for admins managing Linux servers in production.
85. What command would you use to check filesystem corruption?
The fsck
command scans and repairs filesystem errors.
- Uses
fsck /dev/sda1
- Runs in single-user mode
- Ensures integrity, a core Linux task
This prevents data loss in Linux systems.
86. How would you use a command to monitor system calls?
sudo strace -p 1234
Use strace
to trace system calls for a process. This debugs application issues, a core task for admins troubleshooting Linux servers in production.
87. Why would you use sar
to monitor Linux performance?
- Tracks CPU usage
- Monitors disk I/O
- Generates reports
Thesar
command collects performance metrics.
It aids optimization.
This is vital for Linux server efficiency.
Cloud and Container Commands
88. When would you use docker
to manage containers on a Linux server?
The docker
command manages containers for application deployment.
- Builds with
docker build
- Runs with
docker run
- Enhances portability, a core Linux principle
89. Where would you use a command to check container status?
- Use
docker ps
- Lists running containers
- Shows status
Thedocker ps
command monitors containers.
This ensures application uptime.
Admins use it for Linux container management.
90. Which command checks Kubernetes pod health on a Linux server?
kubectl get pods
Use kubectl get pods
to check pod status. This ensures cluster health, a critical task for admins managing Linux-based Kubernetes deployments.
91. What command would you use to monitor container resource usage?
The docker stats
command tracks container CPU and memory usage.
- Uses
docker stats --format
- Monitors performance
- Optimizes resources, a core Linux task
This ensures efficient container operations in Linux systems.
92. How would you use a command to scale a Kubernetes deployment?
kubectl scale deployment myapp --replicas=3
Use kubectl scale
to adjust deployment replicas. This ensures scalability, a core task for admins managing Linux-based Kubernetes clusters in production.
93. Why would you use kubectl
to troubleshoot Kubernetes issues?
- Inspects pods
- Checks logs
- Diagnoses failures
Thekubectl
command debugs Kubernetes clusters.
It pinpoints issues.
This is vital for Linux-based cloud deployments.
94. When would you use docker-compose
on a Linux server?
The docker-compose
command manages multi-container applications.
- Defines services in YAML
- Runs with
docker-compose up
- Simplifies deployments, a core Linux principle
95. Where would you use a command to check cloud instance status?
- Use
aws ec2 describe-instances
- Shows instance details
- Verifies status
The AWS CLI command monitors cloud instances.
This ensures uptime.
Admins rely on it for Linux cloud management.
96. Which command pulls a Docker image on a Linux server?
docker pull nginx:latest
Use docker pull
to download a container image. This prepares deployments, a critical task for admins managing Linux-based containerized applications.
97. What command would you use to monitor AWS EC2 metrics?
The aws cloudwatch
command retrieves EC2 performance metrics.
- Uses
aws cloudwatch get-metric-statistics
- Tracks CPU usage
- Optimizes performance, a core Linux task
This ensures efficient cloud operations in Linux systems.
98. How would you use a command to configure a Kubernetes service?
kubectl expose deployment myapp --port=80 --type=LoadBalancer
Use kubectl expose
to create a service for a deployment. This enables access, a core task for admins managing Linux-based Kubernetes clusters.
99. Why would you use prometheus
to monitor a Linux server?
- Collects metrics
- Generates alerts
- Tracks performance
Theprometheus
command monitors system health.
It aids optimization.
This is vital for Linux server reliability.
100. When would you use aws
CLI to manage Linux instances?
The aws
CLI manages EC2 instances for cloud operations.
- Starts with
aws ec2 start-instances
- Stops with
aws ec2 stop-instances
- Enhances automation, a core Linux principle
101. Where would you use a command to check container logs?
- Use
docker logs
- Shows container output
- Aids debugging
Thedocker logs
command inspects container issues.
This is critical for troubleshooting.
Admins use it for Linux container management.
102. Which command restarts a Kubernetes pod on a Linux server?
kubectl delete pod mypod --force
Use kubectl delete
to restart a pod by force. This resolves issues, a critical task for admins managing Linux-based Kubernetes clusters.
103. What command would you use to check cloud network configurations?
The aws ec2 describe-security-groups
command lists security group rules.
- Verifies inbound rules
- Checks outbound access
- Ensures connectivity, a core Linux task
This maintains secure cloud networking in Linux systems.
104. How would you use a command to monitor Kubernetes cluster health?
kubectl cluster-info
kubectl get nodes
Use kubectl
to check cluster and node status. This ensures reliability, a core task for admins managing Linux-based Kubernetes deployments.
105. Why would you use terraform
to manage Linux infrastructure?
- Defines infrastructure as code
- Automates provisioning
- Ensures consistency
Theterraform
command streamlines cloud setups.
It supports scalability.
This is vital for Linux-based cloud environments.
Tips to Ace Linux Command-Based Interviews
- Practice core Linux commands
- Build scripting and automation labs
- Master
systemctl
,journalctl
, andkubectl
- Study networking and security commands
- Review Linux documentation
- Explain command usage clearly with technical precision
What's Your Reaction?






