env.dev

Linux Commands Cheat Sheet — Quick Reference

Linux commands quick reference: file management, process control, networking, permissions, systemd, and disk usage.

Last updated:

A quick reference for essential Linux commands. Covers file management, process control, networking, permissions, systemd, and disk usage.

File Management

CommandDescription
ls -laList all files with details
cp -r src/ dest/Copy directory recursively
mv old newMove or rename file/directory
rm -rf dir/Remove directory and contents
find . -name "*.log"Find files by name pattern
find . -mtime -7Find files modified in last 7 days
mkdir -p a/b/cCreate nested directories
ln -s target linkCreate symbolic link
tar -czf archive.tar.gz dir/Create gzipped tar archive
tar -xzf archive.tar.gzExtract gzipped tar archive

Process Control

CommandDescription
ps auxList all running processes
topInteractive process viewer
htopEnhanced interactive process viewer
kill <pid>Send SIGTERM to process
kill -9 <pid>Force kill process (SIGKILL)
killall <name>Kill all processes by name
bg / fgResume job in background / foreground
nohup cmd &Run command immune to hangups
jobsList background jobs

Networking

CommandDescription
curl -O <url>Download file from URL
curl -X POST -d @data.json <url>Send POST request with data
wget <url>Download file (with resume support)
ss -tulnpShow listening ports with process info
ip addrShow network interfaces and IPs
ping -c 4 hostSend 4 ICMP echo requests
dig example.comDNS lookup
traceroute hostTrace packet route to host
netstat -tulnpShow listening ports (legacy)

Permissions

CommandDescription
chmod 755 filerwxr-xr-x — owner full, others read/execute
chmod 644 filerw-r--r-- — owner read/write, others read
chmod +x script.shAdd execute permission
chmod -R 750 dir/Set permissions recursively
chown user:group fileChange file owner and group
chown -R user dir/Change ownership recursively
umask 022Set default permission mask
stat fileShow file permissions and metadata

Systemd

CommandDescription
systemctl start <service>Start a service
systemctl stop <service>Stop a service
systemctl restart <service>Restart a service
systemctl status <service>Check service status
systemctl enable <service>Enable service on boot
systemctl disable <service>Disable service on boot
journalctl -u <service> -fFollow service logs
systemctl list-units --type=serviceList all loaded services

Disk Usage

CommandDescription
df -hShow disk space usage (human readable)
du -sh dir/Show directory size
du -h --max-depth=1Show size of immediate subdirectories
lsblkList block devices
mount /dev/sda1 /mntMount a filesystem
umount /mntUnmount a filesystem
fdisk -lList disk partitions
ncduInteractive disk usage analyzer

Text Processing

CommandDescription
grep -r "pattern" .Search recursively in files
grep -i "pattern" fileCase-insensitive search
sed -i "s/old/new/g" fileFind and replace in file
awk '{print $1}' filePrint first column
sort file | uniq -cCount unique lines
wc -l fileCount lines in file
head -n 20 fileShow first 20 lines
tail -f fileFollow file output in real time

Frequently Asked Questions

What is the difference between chmod and chown?

chmod changes file permissions (read/write/execute). chown changes file ownership (user and group). Both require appropriate privileges — typically root or the file owner.

How do I find files in Linux?

Use find for complex searches: find /path -name "*.txt" -mtime -7. Use locate for fast name lookups (uses a database). Use which or whereis to find executables.

How do I manage services with systemd?

systemctl start/stop/restart service — manage service state. systemctl enable/disable service — control auto-start at boot. journalctl -u service — view service logs.