Thuta Learning
Linux
BasicDevOps & ToolsBeginner

mkdir, touch, rm, rmdir

LinuxLesson 8

What you'll walk away with

  • Understand mkdir, touch, rm, and rmdir, without the intimidation
  • Get comfortable trying out commands yourself in the terminal
  • See how these commands are actually useful on a real server or project

Let's think about it this way for a second

mkdir (make directory) creates a new folder. touch creates an empty file (or updates the timestamp of one that already exists). rmdir can only delete an empty folder — it'll throw an error if there's anything inside. rm deletes files, and rm -r deletes an entire folder along with everything in it. Here's the most important thing to remember — Linux has no Recycle Bin. rm deletes instantly and permanently.

Let's connect this to a real-world scenario

Copy-pasting rm -rf from Google without understanding it is a recurring theme in beginner horror stories — the -f (force) flag deletes without asking for confirmation, so if you run it against the wrong folder, there's no getting it back. A safer habit is to run ls first to check exactly what you're about to delete — like checking what's in the gas tank before you light the match.

Let's try it together in the terminal

bash
mkdir practice
touch practice/notes.txt
ls practice
rmdir practice        # folder ထဲမှာ file ရှိလို့ error ပြမည်
rm practice/notes.txt
rmdir practice        # အခု အလုပ်ဖြစ်မည်
You should see
You can create a practice folder, create notes.txt inside it, and then successfully delete the folder.

5-minute try-it

mkdir a folder called test-folder. touch 2 files inside it. Then clean it all up at once with rm -r.

A quick word of caution

Before running rm -rf, always check pwd first to confirm 'where am I right now.' Running rm -rf * in the wrong folder can leave damage there's no fixing.

Easy traps

  • Thinking rm sends files to a Recycle Bin — it actually deletes them instantly
  • Accidentally running rm -rf / or rm -rf * while in the wrong folder

Now try it yourself

mkdir a folder called test-folder. touch 2 files inside it. Then clean it all up at once with rm -r.

You'll know it worked when: You can create a practice folder, create notes.txt inside it, and then successfully delete the folder.

Updated on

Progress is saved only in this browser on this device. It isn't synced to other devices.

Report a problem with this lessonOpens your email app with this lesson's address filled in — nothing is sent until you send it.

mkdir, touch, rm, rmdir | Thuta Learning