Loading...

20 most used Linux commands to troubleshoot issues

question linux
Ram Patra Published on July 15, 2024

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

  1. top: Provides a dynamic, real-time view of the system’s processes. Useful for checking CPU and memory usage.

    top
    
  2. htop: An enhanced version of top, with a more user-friendly interface (if installed).

    htop
    
  3. free -m: Displays memory usage, with -m showing the information in megabytes.

    free -m
    
  4. vmstat: Reports virtual memory statistics.

    vmstat 5
    
  5. iostat: Provides CPU and I/O statistics. Useful for diagnosing disk performance issues.

    iostat
    

Disk Usage and Space

  1. df -h: Shows disk space usage in a human-readable format.

    df -h
    
  2. du -sh *: Displays the disk usage of files and directories in the current directory, summarized and human-readable.

    du -sh *
    

Network

  1. ping: Checks the network connectivity between the host and a target IP or domain.

    ping google.com
    
  2. netstat -tuln: Lists all listening ports and their respective services.

    netstat -tuln
    
  3. ss -tuln: A modern replacement for netstat, displaying listening sockets.

    ss -tuln
    
  4. traceroute: Traces the route packets take to a network host.

    traceroute google.com
    
  5. ifconfig or ip addr: Displays network interfaces and their configurations.

    ifconfig
    ip addr
    

Processes and Services

  1. ps aux: Lists all running processes with detailed information.

    ps aux
    
  2. systemctl status <service>: Checks the status of a specific service.

    systemctl status apache2
    
  3. journalctl -xe: Views system logs, particularly useful for diagnosing issues with services managed by systemd.

    journalctl -xe
    

Logs and Files

  1. tail -f /var/log/syslog: Monitors the system log file in real-time.

    tail -f /var/log/syslog
    
  2. dmesg: Displays kernel-related messages.

    dmesg
    

System Information

  1. uname -a: Displays detailed information about the system, including the kernel version.

    uname -a
    
  2. uptime: Shows how long the system has been running, along with the load average.

    uptime
    
  3. 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.

Presentify

Take your presentation to the next level.

FaceScreen

Put your face and name on your screen.

ToDoBar

Your to-dos on your menu bar.

Ram Patra Published on July 15, 2024
Image placeholder

Keep reading

If this article was helpful, others might be too

question networking linux July 19, 2024 How to fetch the nameservers of a domain?

To get the nameservers of a domain, you can use the nslookup or dig command-line tools. Both are available on most Unix-like operating systems, including Linux and macOS. On Windows, nslookup is available by default.