Linux Commands

Linux command cheat-sheet

Navigation
pwd
Current directory
ls
List files
ls -l
Detailed list
ls -la
Show hidden files too
ls -lh
Human-readable sizes
cd folder
Enter folder
cd ..
Go up one level
cd ~
Home directory
tree
Show folder structure
Files & Folders
touch file.txt
Create file
mkdir folder
Create folder
mkdir -p a/b/c
Create nested folders (parents)
cp file backup
Copy file
cp -r folder backup
Copy folder recursively
mv old new
Rename or move
rm file
Delete file
rm -r folder
Delete folder and contents
rm -rf folder
Force delete (use with care)
rmdir folder
Delete empty folder
Viewing Files
cat file.txt
Display file
less file.txt
View file page by page
more file.txt
Another pager
head file.txt
head -n 20 file.txt
Show top lines (optionally first 20)
tail file.txt
tail -n 20 file.txt
tail -f logfile.log
Tail file; follow live with -f
nl file.txt
Show line numbers
Searching
find . -name "*.txt"
Find files by name
find . -type f
Find files (type f)
grep word file.txt
grep -i word file.txt
grep -r word folder
Search inside files
locate firefox
which firefox
whereis firefox
Locate binaries or packages
Permissions
chmod +x script.sh
chmod 755 file
chmod 644 file
Change permissions
chown user file
chown user:group file
Change owner and group
755 = Owner full, others read+execute
644 = Owner write, others read
777 = Everyone everything
600 = Private file
Common permission meanings
Processes
ps
ps aux
List processes
top
htop
Interactive monitors
kill PID
kill -9 PID
pkill firefox
pgrep firefox
Terminate or find processes
System Information
uname -a
hostname
uptime
whoami
id
Basic system and user info
free -h
df -h
du -sh folder
lsblk
lscpu
neofetch
Memory, disks and hardware info
Networking
ping google.com
ip a
ip r
curl https://example.com
wget URL
traceroute google.com
ss -tulpn
Common networking commands
Archives
tar -cvf archive.tar folder
tar -xvf archive.tar

tar -czvf archive.tar.gz folder
tar -xzvf archive.tar.gz

zip file.zip folder
unzip file.zip
Create and extract archives
Pacman (EndeavourOS)
sudo pacman -Syu   # Update everything
sudo pacman -S package
sudo pacman -R package
sudo pacman -Rns package
pacman -Ss firefox
pacman -Qs firefox
pacman -Si firefox
pacman -Qi firefox
pacman -Q
pacman -Qe
pacman -Qdt
sudo pacman -Sc
sudo pacman -Scc
Common pacman package manager commands
Yay (AUR)
yay -S package
yay -R package
yay -Ss package
yay -Syu
AUR helper commands
Services (systemd)
systemctl status service
sudo systemctl start service
sudo systemctl stop service
sudo systemctl restart service
sudo systemctl enable service
sudo systemctl disable service

# Example
sudo systemctl restart NetworkManager
Manage systemd services
Logs
journalctl
journalctl -xe
journalctl -u service
journalctl -f
View systemd journal logs
Disks
lsblk
blkid
mount
umount /dev/sdb1
df -h
Disk and mount utilities
Users
who
w
users
sudo useradd bob
sudo passwd bob
sudo userdel bob
User account and session commands
SSH
ssh user@host
scp file user@host:/folder
ssh-keygen
ssh-copy-id user@host
Remote shell and key setup
KDE Plasma
kquitapp6 plasmashell
plasmashell &

# or
plasmashell --replace &
Restart Plasma shell
Hardware
lspci
lsusb
inxi -F
sensors
xrandr
Hardware inspection tools
Git
git clone URL
git status
git add .
git commit -m "message"
git push
git pull
Common Git commands
Useful Terminal Tricks
sudo command
command &   # run in background
# Stop current process: Ctrl+C
# Suspend process: Ctrl+Z
clear
Ctrl+L
Quick terminal tips
Most Common Flags
-a  All
-A  Almost all
-l  Long listing
-h  Human readable
-r  Recursive / reverse
-R  Recursive
-i  Interactive
-f  Force
-v  Verbose
-q  Quiet
-s  Search / summarize
-u  Update
-y  Refresh databases
-x  Extract
-c  Create
-z  Gzip
-n  Number / no config
-e  Enable
-d  Delete / dependencies
-p  Parents
--help  Show help
--version  Show version
Common flags and meanings