Guides
Linux Commands
Quick Reference
This page covers the most commonly used Linux commands, grouped by purpose. It's designed as a practical baseline for anyone working with Linux systems.
📁 File & Directory Management
ls – List directory contents
bash
ls
ls -l # detailed list
ls -a # include hidden files
ls -lh # human-readable sizescd – Change directory
bash
cd /path/to/dir
cd .. # go up one level
cd ~ # go to home directorypwd – Print working directory
bash
pwdmkdir – Create directories
bash
mkdir new_folder
mkdir -p a/b/c # create nested directoriesrm – Remove files/directories
bash
rm file.txt
rm -r folder/ # recursive delete
rm -rf folder/ # force delete (dangerous)cp – Copy files/directories
bash
cp file1 file2
cp -r dir1 dir2mv – Move/rename files
bash
mv old.txt new.txt
mv file.txt /path/📄 File Viewing & Editing
cat – Display file content
bash
cat file.txtless – View file (scrollable)
bash
less file.txthead / tail – Preview file sections
bash
head file.txt # first 10 lines
tail file.txt # last 10 lines
tail -f log.txt # follow live logsnano / vim – Text editors
bash
nano file.txt
vim file.txt🔍 Search & Filtering
grep – Search text
bash
grep "text" file.txt
grep -r "text" /dir # recursive
grep -i "text" file # case-insensitivefind – Locate files
bash
find /path -name file.txt
find . -type f -name "*.log"locate – Fast file search (database-based)
bash
locate filename⚙️ System Information
uname – System info
bash
uname -atop / htop – Process viewer
bash
top
htopdf – Disk usage
bash
df -hdu – Directory size
bash
du -sh *free – Memory usage
bash
free -h👤 Permissions & Ownership
chmod – Change permissions
bash
chmod 755 file
chmod +x script.shchown – Change ownership
bash
chown user:group file🔄 Process Management
ps – List processes
bash
ps auxkill – Terminate process
bash
kill PID
kill -9 PID # force killpkill – Kill by name
bash
pkill nginx🌐 Networking
ip – Network configuration
bash
ip a
ip rping – Test connectivity
bash
ping google.comcurl – HTTP requests
bash
curl https://example.comwget – Download files
bash
wget https://example.com/file.zip📦 Package Management (Debian/Ubuntu)
apt – Package manager
bash
apt update
apt upgrade
apt install package
apt remove package📜 Archives & Compression
tar – Archive files
bash
tar -cvf archive.tar folder/
tar -xvf archive.targzip / gunzip
bash
gzip file
gunzip file.gz🔐 Sudo & User Control
sudo – Run as superuser
bash
sudo commandwhoami – Current user
bash
whoami🧠 Useful Shortcuts & Tips
Ctrl + C→ Stop current commandCtrl + Z→ Suspend processCtrl + R→ Search command history!!→ Repeat last commandhistory→ Show command history
🧩 Pro Tips
- Combine commands with pipes:
bash
cat file.txt | grep "error"- Redirect output:
bash
command > output.txt # overwrite
command >> output.txt # append- Use tab completion to speed up typing.
⚠️ Common Pitfalls
rm -rf /→ catastrophic (never run blindly)- Always double-check paths when using
sudo - Be cautious with wildcards (
*)