Cheatography
https://cheatography.com
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 partitions, sizes, and types with the command. |
du -ah |
See disk usage for all files and directories. |
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 [device_path] [mount_point] |
Mount a device. |
|
Services that are on and off Commands
service --status-all |
List all services. |
systemctl list-units --type=service |
List all services. |
systemctl list-units --type=service --all |
List all services. |
systemctl list-units --type=service --state=running |
List all running services. |
systemctl list-units -a --state=active |
List all active services. |
systemctl list-units -a --state=inactive |
List inactive service units. |
systemctl list-units --state=failed |
List failed services for troubleshooting. |
systemctl list-unit-files --type=service --state=enabled |
Show services enabled on Linux boot. |
sudo systemctl list-units --type=service --state=exited |
List every loaded service that is in the exited state. |
|
Memory Usage Commands
lscpu |
See CPU information. |
lsblk |
See information 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 configuration information. |
cat /proc/cpuinfo |
Show detailed CPU information. |
cat /proc/meminfo |
View detailed system memory information. |
cat /proc/mounts |
See mounted file systems. |
free -h |
Display free and used memory. |
sudo dmidecode |
Show hardware information from the BIOS. |
hdparm -i /dev/[device_name] |
Display disk data information. |
hdparm -tT /dev/[device_name] |
Conduct a read speed test on the device/disk. |
badblocks -s /dev/[device_name] |
Test for unreadable blocks on the device/disk. |
fsck /dev/[device_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 |
Interactive and colorful process viewer. |
kill [process_id] |
Terminate a Linux process under a given ID. |
pkill [process_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 [process_name] |
Show the PID of a process. |
bg |
List and resume stopped jobs in the background. |
fg |
Bring the most recently suspended job to the foreground. |
fg [job] |
Bring a particular job to the foreground. |
lsof |
List files opened by running processes with lsof command. |
trap "[commands]" [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 background. |
|