Skip to main content
TellaDev
Cheatsheets Linux Commands

48 entries

Linux Commands

Essential Linux commands for files, processes, networking, and system administration

48 commands

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/user
cp -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/ui
find . -name "*.log"
Find files matching a pattern recursively
find /var -name '*.log' -mtime -7
ln -s <target> <link>
Create a symbolic link
ln -s /opt/app/bin/app /usr/local/bin/app
touch <file>
Create an empty file or update its timestamp
touch README.md
ps aux
Show all running processes with details
ps aux | grep node
kill -9 <pid>
Force kill a process by PID
kill -9 12345
top
Interactive process viewer with CPU and memory usage
top -o %MEM
htop
Enhanced interactive process viewer (requires installation)
htop
bg %1
Resume a stopped job in the background
bg %1
fg %1
Bring a background job to the foreground
fg %1
nohup <cmd> &
Run command immune to hangups, in background
nohup ./server.sh &
ping <host>
Send ICMP echo requests to test connectivity
ping -c 4 google.com
curl -I <url>
Fetch HTTP response headers only
curl -I https://api.example.com/health
wget <url>
Download a file from the web
wget https://example.com/file.tar.gz
netstat -tuln
Show listening TCP and UDP ports
netstat -tuln | grep :3000
ss -tuln
Show socket statistics (modern netstat replacement)
ss -tuln | grep LISTEN
ssh user@host
Connect to a remote host via SSH
scp <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/usb
lsblk
List block devices and their mount points
lsblk
whoami
Print the current logged-in user
whoami # deploy
sudo <cmd>
Execute a command as the superuser
sudo systemctl restart nginx
useradd <name>
Create a new user account
sudo useradd -m devuser
passwd <user>
Change a user's password
sudo passwd devuser
chmod 755 <file>
Set file permissions (rwxr-xr-x)
chmod 755 deploy.sh
chown user:group <file>
Change file owner and group
chown www:www /var/www/html
chmod +x <file>
Make a file executable
chmod +x ./start.sh
grep -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.yml
awk '{print $1}' <file>
Print the first field of each line
awk '{print $1, $3}' access.log
sort -u <file>
Sort lines and remove duplicates
sort -u emails.txt
wc -l <file>
Count the number of lines in a file
wc -l *.py
tail -f <file>
Follow a file's output in real time
tail -f /var/log/syslog
uname -a
Print all system information (kernel, architecture, etc.)
uname -a
uptime
Show how long the system has been running and load average
uptime
free -h
Show memory usage in human-readable format
free -h
history
Show command history
history | grep ssh
crontab -e
Edit the current user's cron jobs
crontab -e
systemctl status <service>
Show the status of a systemd service
systemctl status nginx
journalctl -u <service> -f
Follow live logs for a systemd service
journalctl -u nginx -f