Chapter 4
Time to get our hands dirty — Linux isn’t just about looking at files, it’s about making, breaking, moving, and linking them like a boss.
In this chapter, you’ll learn:
How to create directories (
mkdir)How to copy stuff (
cp)How to move and rename stuff (
mv)How to delete (danger zone!) with
rmHow to link files together with
lnHow to use wildcards to work with many files at once
And yes… we’re going to build a playground so you don’t blow up your system while practicing. 😏
🎮 Step 1: Build a Playground
Let’s not experiment on important files — that’s like learning to drive by practicing in a Ferrari showroom.
Make a safe place in your home directory:
cd ~
mkdir playground
cd playgroundFrom now on, all examples happen in ~/playground.
🏗️ mkdir — Make New Directories
mkdir — Make New DirectoriesThink of mkdir as “summon a new folder.”
Cool tricks:
mkdir -p project/src/assets→ makes a whole tree at once 🌳mkdir -v demo→ Linux politely tells you what it made
👉 Try:
📋 cp — Copy Files Like a Wizard
cp — Copy Files Like a Wizardcp = duplicate files. It doesn’t teleport them, it clones them.
Useful options:
-i→ ask before overwriting (cp -i a b)-r→ copy folders recursively (cp -r dir1 dir2)-u→ only copy if newer
👉 Playground Test:
🚚 mv — Move or Rename
mv — Move or RenameThis one is sneaky: it both renames and moves.
Options:
-i→ ask before overwriting
👉 Try this:
💀 rm — Remove (Danger Zone!)
rm — Remove (Danger Zone!)The most feared command. rm permanently deletes things. There’s no recycle bin. No undo. Just void.
Options:
-i→ confirm before deleting-r→ delete folders recursively-f→ force delete, no questions asked 😈
⚠️ Scary Story Time: You wanted to delete .html files:
👉 Safety Tip: Always test wildcards with ls first:
If it shows the right files, then press ↑ and replace ls with rm.
🔗 ln — Hard & Symbolic Links
ln — Hard & Symbolic LinksLinks are like extra doorways to the same file.
🔹 Hard Links
Multiple names for one file
File survives until all links are gone
Can’t cross file systems, can’t link directories
Example:
Now hello.txt and hello_hard are the same file. Edit one, the other changes too.
🔹 Symbolic Links (Symlinks)
Modern, flexible
Works like Windows shortcuts
Can link across file systems, can point to directories
If the original dies, the symlink is “broken” (ls often shows it in red)
Example:
👉 Test it:
You wrote to the symlink, the original changed. Magic! ✨
🎭 Wildcards — Work With Many Files at Once
Wildcards = pattern matching for filenames.
*
Matches any characters
ls *.txt → all .txt files
?
Matches a single character
ls file?.txt → file1.txt but not file10.txt
[abc]
Matches a, b, or c
ls [abc]*
[!0-9]
Matches anything not a digit
ls [!0-9]*
[[:upper:]]
Uppercase letters
ls [[:upper:]]*
👉 Try:
✅ Recap
mkdirmakes folderscpcopiesmvmoves/renamesrmdeletes (handle with care!)lnmakes links (hard vs symlink)Wildcards let you target groups of files like a pro
And remember: always practice inside your playground before unleashing these commands on your real system.
Last updated