Displays the current directory path you're working in.
pwd
/home/tom
List files and directories. Common flags:
ls -la
ls -l
Long format with details
ls -a
Show hidden files
ls -lh
Human-readable sizes
ls -R
Recursive listing
Navigate between directories.
cd /var/www/html
cd ~
Go to home directory
cd ..
Go up one level
cd -
Go to previous directory
cd /
Go to root directory
Create new directories.
mkdir myproject
mkdir -p projects/website/assets
Create nested directories with -p (parent) flag
Create empty files or update timestamps.
touch index.html style.css app.js
Copy files and directories.
cp file.txt backup.txt cp -r project/ project-backup/
Move or rename files and directories.
mv file.txt /path/to/new/location/ mv oldname.txt newname.txt
Remove files and directories. Use with caution!
rm file.txt rm -rf directory/
Warning: rm -rf permanently deletes files without sending them to trash. Always double-check before running.
View file contents or combine multiple files.
cat file.txt cat file1.txt file2.txt > combined.txt
Search for patterns in files using regular expressions.
grep "error" log.txt grep -r "TODO" --include="*.py" .
grep -i
Case-insensitive search
grep -n
Show line numbers
grep -v
Invert match (exclude)
grep -c
Count matching lines
Modify file permissions (read, write, execute).
chmod +x script.sh chmod 755 file.txt chmod -R 644 public/
Change file owner and group.
sudo chown tom:tom file.txt sudo chown -R www-data:www-data /var/www/
View running processes.
ps aux ps aux | grep nginx
Real-time view of system processes and resource usage.
top htop # Install with: sudo apt install htop
Check disk space and directory sizes.
df -h du -sh /home/tom/*
You've learned the 15 most essential Linux commands. Practice makes perfect!