Files, permissions, processes, disks, logs and performance commands you reach for daily.
In the print dialog, choose "Save as PDF" as the destination.
Navigate and inspect
Command
What it does
pwd
Print the current directory
ls -lah
Long list, hidden files, human sizes
cd -
Return to the previous directory
tree -L 2
Show a directory tree two levels deep
stat file
Size, owner, permissions and timestamps
file name
Detect the type of a file
du -sh * | sort -h
Size of each item here, smallest to largest
Find
find /var/log -type f -mtime -1 -size +1M # modified in the last day, larger than 1 MB
find . -name "*.conf" -not -path "./tmp/*"# by name, excluding a path
grep -rn "error" /etc/nginx # search file contents recursivelytype -a python3 # which executable runs
Copy, move, link
cp -a src/ dst/ # copy keeping permissions and linksmv old new # rename or moveln -sfn target linkname # replace a symlink to a directory safelyreadlink -f linkname # resolve the final path
Users and permissions
Command
What it does
id
Your user, group IDs and groups
sudo -l
What you may run with sudo
chmod 640 file
Owner read/write, group read, others nothing
chmod u+x script.sh
Add execute for the owner
chown app:app file
Change owner and group
umask
Default permission mask for new files
Permission digits: read = 4, write = 2, execute = 1. Add them per class (owner, group, others), so 755 is rwxr-xr-x.
useradd -m -s /bin/bash deploy # create a user with a home directory
usermod -aG docker deploy # add to a group (keep existing ones)
passwd -l olduser # lock an account
getent passwd deploy # look up through all name sources
Processes and services
ps aux --sort=-%mem | head# top memory users
ps -eo pid,ppid,stat,cmd | grep defunct # find zombies
top -o %CPU # live view sorted by CPUkill -TERM 1234 # polite stopkill -KILL 1234 # last resort, cannot be caught
pgrep -af nginx # find by name with full command
systemctl status nginx # state and recent log lines
systemctl enable --now nginx # start now and at boot
systemctl restart nginx
systemctl list-units --failed # everything that failed
systemctl daemon-reload # after editing a unit file
Disks and filesystems
df -hT # space per filesystem with typedf -i # inode usage (full inodes also stop writes)
lsblk -f # block devices and filesystems
findmnt /data # where and how a path is mounteddu -xh / --max-depth=1 2>/dev/null | sort -h | tail
lsof +L1 # deleted files still held open