| Command | Purpose | Example |
|---|---|---|
ls |
π List directory contents | ls |
ls -l |
π Long format with details | ls -l |
ls -la |
ποΈ Include hidden files | ls -la |
ls -lh |
π Human readable sizes | ls -lh |
pwd |
π Print working directory | pwd |
cd |
πΆ Change directory | cd /etc |
cd .. |
β¬οΈ Go up one level | cd .. |
cd - |
β©οΈ Go to previous directory | cd - |
# π Create files
touch filename.txt
touch file1.txt file2.txt file3.txt
# π Create directories
mkdir dirname
mkdir project
# ποΈ Create nested directories
mkdir -p path/to/nested/directories
mkdir -p project/src/main/java
# πβ‘οΈπ Copy files
cp file1.txt file2.txt
cp report.txt backup.txt
# πβ‘οΈπ Copy directories (recursive)
cp -r directory1 directory2
cp -r project project-backup
# π Move/rename files
mv oldname.txt newname.txt
mv report.txt final-report.txt
# π¦ Move to different location
mv file.txt /path/to/destination/
mv document.txt ~/Documents/
# β Remove files
rm filename.txt
# β Interactive removal (asks before deleting)
rm -i filename.txt
# πβ Remove empty directories
rmdir empty_directory
# ποΈβ Remove directories with contents
rm -r directory_with_contents
# β οΈ Force remove (be careful!)
rm -rf directory
β οΈ Warning:
rm -rfis permanent! Thereβs no recycle bin in Linux!
| Command | Purpose | Best For |
|---|---|---|
cat filename.txt |
π Display entire file | Small files |
less filename.txt |
π View with paging | Large files |
more filename.txt |
π View with paging (older) | Legacy systems |
head filename.txt |
β¬οΈ First 10 lines | Quick preview |
tail filename.txt |
β¬οΈ Last 10 lines | Log files |
head -20 file.txt |
β¬οΈ First 20 lines | Custom preview |
tail -20 file.txt |
β¬οΈ Last 20 lines | Recent logs |
lessKey Action
βββββββββββββββββββββββββββββββ
Space β¬οΈ Next page
b β¬οΈ Previous page
/pattern π Search forward
?pattern π Search backward
q πͺ Quit
# π Simple text editor (beginner-friendly)
nano filename.txt
# πΎ Save in nano: Ctrl+O, then Enter
# πͺ Exit nano: Ctrl+X
# β¬οΈ Download files from internet
wget https://example.com/file.txt
# π₯ Download with custom name
wget -O newname.txt https://example.com/file.txt
# π Download with progress bar
wget --progress=bar https://example.com/largefile.zip
Next: β Getting Help With Commands
Previous: β Essential Navigation Commands
Lesson Home: β Lesson 2: The Shell
Course Home: β Introduction to Linux