Using the below commands effectively allows for comprehensive troubleshooting and monitoring of a Linux system, helping to quickly identify and resolve issues.
System Performance and Resource Usage
-
top
: Provides a dynamic, real-time view of the system’s processes. Useful for checking CPU and memory usage.top
-
htop
: An enhanced version oftop
, with a more user-friendly interface (if installed).htop
-
free -m
: Displays memory usage, with-m
showing the information in megabytes.free -m
-
vmstat
: Reports virtual memory statistics.vmstat 5
-
iostat
: Provides CPU and I/O statistics. Useful for diagnosing disk performance issues.iostat
Disk Usage and Space
-
df -h
: Shows disk space usage in a human-readable format.df -h
-
du -sh *
: Displays the disk usage of files and directories in the current directory, summarized and human-readable.du -sh *
Network
-
ping
: Checks the network connectivity between the host and a target IP or domain.ping google.com
-
netstat -tuln
: Lists all listening ports and their respective services.netstat -tuln
-
ss -tuln
: A modern replacement fornetstat
, displaying listening sockets.ss -tuln
-
traceroute
: Traces the route packets take to a network host.traceroute google.com
-
ifconfig
orip addr
: Displays network interfaces and their configurations.ifconfig ip addr
Processes and Services
-
ps aux
: Lists all running processes with detailed information.ps aux
-
systemctl status <service>
: Checks the status of a specific service.systemctl status apache2
-
journalctl -xe
: Views system logs, particularly useful for diagnosing issues with services managed bysystemd
.journalctl -xe
Logs and Files
-
tail -f /var/log/syslog
: Monitors the system log file in real-time.tail -f /var/log/syslog
-
dmesg
: Displays kernel-related messages.dmesg
System Information
-
uname -a
: Displays detailed information about the system, including the kernel version.uname -a
-
uptime
: Shows how long the system has been running, along with the load average.uptime
-
lsof
: Lists open files and the processes that opened them. Useful for troubleshooting issues related to files and directories.lsof
If there are any other commands you use on a regular basis that’s not listed above, please feel free to comment.