Show Menu
Cheatography

Linux Troubleshooting Cheat Sheet Cheat Sheet (DRAFT) by

Linux Command line Troubleshooting Cheat Sheet

This is a draft cheat sheet. It is a work in progress and is not finished yet.

Disk Usage Commands

df -h
Check free and use space on mounted systems.
df -i
Show free inodes on mounted file systems.
fdisk -l
Display disk partit­ions, sizes, and types with the command.
du -ah
See disk usage for all files and direct­ories.
du -sh
Show disk usage of the current directory.
mount
Show currently mounted file systems.
findmnt
Display target mount point for all file systems.
mount [devic­e_path] [mount­_point]
Mount a device.

Services that are on and off Commands

service --stat­us-all
List all services.
systemctl list-units --type­=se­rvice
List all services.
systemctl list-units --type­=se­rvice --all
List all services.
systemctl list-units --type­=se­rvice --stat­e=r­unning
List all running services.
systemctl list-units -a --stat­e=a­ctive
List all active services.
systemctl list-units -a --stat­e=i­nactive
List inactive service units.
systemctl list-units --stat­e=f­ailed
List failed services for troubl­esh­ooting.
systemctl list-u­nit­-files --type­=se­rvice --stat­e=e­nabled
Show services enabled on Linux boot.
sudo systemctl list-units --type­=se­rvice --stat­e=e­xited
List every loaded service that is in the exited state.

Memory Usage Commands

lscpu
See CPU inform­ation.
lsblk
See inform­ation about block devices.
lspci -tv
Show PCI devices (graphics card, network card, etc.) in a tree-like diagram.
lsusb -tv
Display USB devices in a tree-like diagram.
lshw
List hardware config­uration inform­ation.
cat /proc/­cpuinfo
Show detailed CPU inform­ation.
cat /proc/­meminfo
View detailed system memory inform­ation.
cat /proc/­mounts
See mounted file systems.
free -h
Display free and used memory.
sudo dmidecode
Show hardware inform­ation from the BIOS.
hdparm -i /dev/[­dev­ice­_name]
Display disk data inform­ation.
hdparm -tT /dev/[­dev­ice­_name]
Conduct a read speed test on the device­/disk.
badblocks -s /dev/[­dev­ice­_name]
Test for unreadable blocks on the device­/disk.
fsck /dev/[­dev­ice­_name]
Run a disk check on an unmounted disk or partition.

Running Processes Commands

ps
List active processes.
pstree
Show processes in a tree-like diagram.
pmap
Display a memory usage map of processes.
top
See all running processes.
htop
Intera­ctive and colorful process viewer.
kill [proce­ss_id]
Terminate a Linux process under a given ID.
pkill [proce­ss_­name]
Terminate a process under a specific name.
killall [label]
Terminate all processes with a given label.
prgrep [keyword]
List processes based on the provided keyword.
pidof [proce­ss_­name]
Show the PID of a process.
bg
List and resume stopped jobs in the backgr­ound.
fg
Bring the most recently suspended job to the foregr­ound.
fg [job]
Bring a particular job to the foregr­ound.
lsof
List files opened by running processes with lsof command.
trap "­[co­mma­nds­]" [signal]
Catch a system error signal in a shell script. Executes provided commands when the signal is caught.
wait
Pause the terminal or a Bash script until a running process is completed.
nohup [command] &
Run a Linux process in the backgr­ound.