📁 Navigation
pwd
Print working directory
beginner
Example
pwdcd
Change directory
beginner
Syntax
cd [directory]
Example
cd /var/log
💡 Pro Tips
- •cd ~ goes to home
- •cd - goes to previous dir
- •cd .. goes up one level
ls
List directory contents
beginner
Syntax
ls [options] [path]
Example
ls -la
💡 Pro Tips
- •-l for long format
- •-a for hidden files
- •-h for human-readable sizes
📄 File Operations
cp
Copy files or directories
beginner
Syntax
cp [options] source dest
Example
cp -r folder1 folder2
💡 Pro Tips
- •-r for recursive (directories)
- •-i for interactive (confirm overwrite)
mv
Move or rename files
beginner
Syntax
mv source dest
Example
mv old.txt new.txtrm
Remove files or directories
⚠️ Caution
beginner
Syntax
rm [options] file
Example
rm -rf directory/
💡 Pro Tips
- •-r for recursive
- •-f for force
- •⚠️ No recycle bin!
mkdir
Create directory
beginner
Syntax
mkdir [options] dirname
Example
mkdir -p path/to/dir
💡 Pro Tips
- •-p creates parent directories too
touch
Create empty file or update timestamp
beginner
Example
touch newfile.txt👁️ View & Search
cat
Display file contents
beginner
Example
cat file.txtless
View file with pagination
beginner
Example
less /var/log/syslog
💡 Pro Tips
- •q to quit
- •/ to search
- •n for next match
head
Show first lines of file
beginner
Syntax
head -n [lines] file
Example
head -n 20 file.txttail
Show last lines of file
beginner
Syntax
tail [options] file
Example
tail -f /var/log/syslog
💡 Pro Tips
- •-f follows file in real-time (great for logs)
grep
Search text patterns
beginner
Syntax
grep [options] pattern file
Example
grep -r 'error' /var/log/
💡 Pro Tips
- •-i case insensitive
- •-r recursive
- •-n show line numbers
find
Find files and directories
intermediate
Syntax
find path -name pattern
Example
find /home -name '*.txt'
💡 Pro Tips
- •-type f for files
- •-type d for directories
- •-mtime for modified time
🔐 Permissions
chmod
Change file permissions
intermediate
Syntax
chmod [mode] file
Example
chmod 755 script.sh
💡 Pro Tips
- •755 = rwxr-xr-x
- •644 = rw-r--r--
- •+x to add execute
chown
Change file owner
intermediate
Syntax
chown user:group file
Example
chown www-data:www-data /var/wwwsudo
Run as superuser
beginner
Syntax
sudo command
Example
sudo apt update
💡 Pro Tips
- •sudo -i for root shell
- •sudo -u user for specific user
📊 System Info
df
Disk space usage
beginner
Example
df -h
💡 Pro Tips
- •-h for human-readable sizes
du
Directory size
beginner
Syntax
du [options] path
Example
du -sh /var/
💡 Pro Tips
- •-s for summary
- •-h for human-readable
top
Real-time process monitor
beginner
Example
top
💡 Pro Tips
- •q to quit
- •k to kill process
- •M to sort by memory
ps
List running processes
beginner
Example
ps aux
💡 Pro Tips
- •aux shows all processes
- •-ef is alternative format
free
Memory usage
beginner
Example
free -h🌐 Network
ping
Test network connectivity
beginner
Syntax
ping [options] host
Example
ping -c 4 google.com
💡 Pro Tips
- •-c count to limit pings
curl
Transfer data from URLs
intermediate
Syntax
curl [options] URL
Example
curl -I https://example.com
💡 Pro Tips
- •-I for headers only
- •-o to save to file
- •-X for HTTP method
wget
Download files
beginner
Syntax
wget [options] URL
Example
wget https://example.com/file.zipssh
Secure shell connection
beginner
Syntax
ssh user@host
Example
ssh admin@192.168.1.100
💡 Pro Tips
- •-p for custom port
- •-i for identity file
scp
Secure copy over SSH
intermediate
Syntax
scp source user@host:dest
Example
scp file.txt user@server:/home/Quick Reference Table
| Command | Purpose | Example |
|---|---|---|
pwd | Where am I? | pwd |
ls -la | List all files | ls -la /etc/ |
cd | Change directory | cd /var/log |
cat | View file | cat file.txt |
grep | Search text | grep 'error' log.txt |
find | Find files | find / -name '*.conf' |
chmod | Change permissions | chmod 755 script.sh |
ps aux | List processes | ps aux | grep nginx |
df -h | Disk usage | df -h |
free -h | Memory usage | free -h |
💡 Tip: Combine commands with pipes (|) for powerful workflows!
# Find large log files
find /var/log -type f -size +100M | head -10
# Search for errors in logs
grep -r 'error' /var/log/ | tail -20
# Check who's using the most disk space
du -sh /* 2>/dev/null | sort -rh | head -10