Cheatsheets
Linux Commands
48 entries
Linux Commands
Essential Linux commands for files, processes, networking, and system administration
48 commands
CommandDescriptionExample
ls -la
List all files including hidden, with details
ls -la /var/log/cd <dir>
Change to a directory
cd /etc/nginx/pwd
Print current working directory
pwd # /home/usercp -r <src> <dst>
Copy files or directories recursively
cp -r ./dist/ /var/www/mv <src> <dst>
Move or rename a file or directory
mv report.txt ~/docs/rm -rf <path>
Remove files or directories recursively and forcefully
rm -rf /tmp/build/mkdir -p <path>
Create directory and any missing parent directories
mkdir -p src/components/uifind . -name "*.log"
Find files matching a pattern recursively
find /var -name '*.log' -mtime -7ln -s <target> <link>
Create a symbolic link
ln -s /opt/app/bin/app /usr/local/bin/apptouch <file>
Create an empty file or update its timestamp
touch README.mdps aux
Show all running processes with details
ps aux | grep nodekill -9 <pid>
Force kill a process by PID
kill -9 12345top
Interactive process viewer with CPU and memory usage
top -o %MEMhtop
Enhanced interactive process viewer (requires installation)
htopbg %1
Resume a stopped job in the background
bg %1fg %1
Bring a background job to the foreground
fg %1nohup <cmd> &
Run command immune to hangups, in background
nohup ./server.sh &ping <host>
Send ICMP echo requests to test connectivity
ping -c 4 google.comcurl -I <url>
Fetch HTTP response headers only
curl -I https://api.example.com/healthwget <url>
Download a file from the web
wget https://example.com/file.tar.gznetstat -tuln
Show listening TCP and UDP ports
netstat -tuln | grep :3000ss -tuln
Show socket statistics (modern netstat replacement)
ss -tuln | grep LISTENscp <file> user@host:<path>
Securely copy a file to a remote host
scp app.zip deploy@srv:/opt/df -h
Show disk space usage in human-readable format
df -h /du -sh <dir>
Show total size of a directory
du -sh ~/projects/mount /dev/sdb1 /mnt
Mount a device to a directory
sudo mount /dev/sdb1 /mnt/usblsblk
List block devices and their mount points
lsblkwhoami
Print the current logged-in user
whoami # deploysudo <cmd>
Execute a command as the superuser
sudo systemctl restart nginxuseradd <name>
Create a new user account
sudo useradd -m devuserpasswd <user>
Change a user's password
sudo passwd devuserchmod 755 <file>
Set file permissions (rwxr-xr-x)
chmod 755 deploy.shchown user:group <file>
Change file owner and group
chown www:www /var/www/htmlchmod +x <file>
Make a file executable
chmod +x ./start.shgrep -r "pattern" <dir>
Search for a pattern recursively in a directory
grep -r 'TODO' src/sed -i 's/old/new/g' <file>
Replace all occurrences of a string in a file
sed -i 's/localhost/0.0.0.0/g' config.ymlawk '{print $1}' <file>
Print the first field of each line
awk '{print $1, $3}' access.logsort -u <file>
Sort lines and remove duplicates
sort -u emails.txtwc -l <file>
Count the number of lines in a file
wc -l *.pytail -f <file>
Follow a file's output in real time
tail -f /var/log/sysloguname -a
Print all system information (kernel, architecture, etc.)
uname -auptime
Show how long the system has been running and load average
uptimefree -h
Show memory usage in human-readable format
free -hhistory
Show command history
history | grep sshcrontab -e
Edit the current user's cron jobs
crontab -esystemctl status <service>
Show the status of a systemd service
systemctl status nginxjournalctl -u <service> -f
Follow live logs for a systemd service
journalctl -u nginx -f