Troubleshooting Commands for Linux Systems

Processes

View processes consuming the most CPU

ps -eo pid,pcpu,comm --sort=-pcpu | head

This command lists processes along with their CPU usage in descending order, showing the top consuming processes.

Network

Trace network route

traceroute ridaeh.com

Traces the route packets take to reach a destination.

List all listening ports

To list all the listening ports, use “-l” flag with ss command. To list specific TCP, UDP or UNIX socket, use “-t”, “-u” and “-x” flag with “-l” as shown below.

$ ss -lt
State      Recv-Q Send-Q      Local Address:Port          Peer Address:Port
LISTEN     0      128                     *:ssh                      *:*
LISTEN     0      50                     :::http-alt                 :::*
LISTEN     0      50                     :::55857                   :::*
LISTEN     0      128                    :::ssh                     :::*
LISTEN     0      50                     :::53285                   :::*