1. What does the 'du' command report?
du (disk usage) estimates the file space used by directories. It’s often paired with sort and head to identify the largest directories consuming disk space.
du -sh * | sort -rh | head -10
Get the Preplance app for a seamless learning experience. Practice offline, get daily streaks, and stay ahead with real-time interview updates.
Get it on
Google Play
4.9/5 Rating on Store
Linux & Shell Scripting · Question Set
System Monitoring, Logs & Networking Commands interview questions for placements and exams.
Questions
14
Included in this set
Subject
Linux & Shell Scripting
Explore more sets
Difficulty
Mixed
Level of this set
Go through each question and its explanation. Use this set as a focused practice pack for Linux & Shell Scripting.
du (disk usage) estimates the file space used by directories. It’s often paired with sort and head to identify the largest directories consuming disk space.
du -sh * | sort -rh | head -10
For complete preparation, combine this set with full subject-wise practice for Linux & Shell Scripting. You can also explore other subjects and sets from the links below.
The df command (disk free) shows available and used disk space for each mounted filesystem. Adding -h makes the output human-readable, showing sizes in MB or GB.
df -h
The uptime command displays the current time, system uptime, number of logged-in users, and the system load averages. It helps assess whether the machine is under heavy load or has been running continuously.
uptime
The free command shows total, used, and available memory including swap space. The -m or -h flag can display values in megabytes or human-readable format.
free -h
netstat shows open ports, listening services, and active connections. Options like -tuln display TCP/UDP sockets numerically without DNS lookups, helping identify which ports are in use.
netstat -tuln
ping sends ICMP echo requests to a host to check if it’s reachable and measures round-trip latency. It’s one of the first commands used for basic network troubleshooting.
ping google.com
traceroute traces each hop packets pass through to reach a target. It’s useful for identifying where network delays or failures occur.
traceroute 8.8.8.8
Using tail -f continuously outputs new lines added to a file. It’s commonly used to monitor live logs like nginx or system logs while debugging.
tail -f /var/log/syslog
Use top or htop to monitor real-time CPU and memory usage. Sort by CPU or memory to identify heavy processes. You can also use ps aux --sort=-%mem | head to list the top memory consumers.
ps aux --sort=-%cpu | head
Start by checking link status with ip a or ifconfig, then test reachability using ping. Next, check DNS with dig or nslookup, and use traceroute to find where packets drop. If still unresolved, verify firewall rules with ufw or iptables.
ping 8.8.8.8 traceroute google.com
The du command is used to measure disk usage recursively. Combine it with sort to list directories from largest to smallest, helping clean up space efficiently.
du -h --max-depth=1 /var | sort -hr | head
Use grep to search for keywords like ERROR or WARNING in log files. Combine with tail -f for real-time tracking during deployments or troubleshooting.
grep 'ERROR' /var/log/app.log | tail -n 20
Use netstat -tulnp or ss -tulnp to list active ports and their associated process IDs. Alternatively, lsof -i :PORT_NUMBER shows which process is bound to that port, helping debug port conflicts.
sudo lsof -i :8080
journalctl queries and displays logs collected by systemd. Options like -u specify a unit, and -f follows logs in real time similar to tail.
journalctl -u nginx -f