World map

 

BM: Baca dalam Bahasa Melayu

World L1: The Shophouse

Delete with care: rm has no undo

You will learn: to delete files and folders safely, because there is no bin.

Checked with Linux (Debian 13) on 1 Nov 2026

The problem

On your laptop, deleted files wait in a bin. On a Linux server, where does rm send them?

Pick one answer.

Watch

You are you in /home/you/kedai. 6 things here. Services: cron running, ssh running, nginx running.

You are hereyou@kedai:~/kedai$

Folder ~/kedai

  • b.tmp (file)-rw-r--r--
  • counter/ (folder)drwxrwxr-xorders.log
  • kitchen/ (folder)drwxrwxr-xrendang.txt sambal.txt
  • menu/ (folder)drwxrwxr-xdrinks.txt today.txt
  • old/ (folder)drwxrwxr-xmenu-2025.txt prices-2025.txt
  • store/ (folder)drwxrwxr-xstock.txt

+ 1 hidden (ls -a)

Services

  • cronrunningstarts at boot
  • sshrunningstarts at boot
  • nginxrunningstarts at boot

rm a.tmp deleted the file. No question, no bin. rm means “remove”. Try rm b.tmp: a Careful note appears.

Predict

old is a folder full of old menus. You type rm old. What does the server say?

Pick one answer.

Try it

Delete the two empty temp files, a.tmp and b.tmp. Keep everything else.

You are you in /home/you/kedai. 7 things here. Services: cron running, ssh running, nginx running.

You are hereyou@kedai:~/kedai$

Folder ~/kedai

  • a.tmp (file)-rw-r--r--
  • b.tmp (file)-rw-r--r--
  • counter/ (folder)drwxrwxr-xorders.log
  • kitchen/ (folder)drwxrwxr-xrendang.txt sambal.txt
  • menu/ (folder)drwxrwxr-xdrinks.txt today.txt
  • old/ (folder)drwxrwxr-xmenu-2025.txt prices-2025.txt
  • store/ (folder)drwxrwxr-xstock.txt

+ 1 hidden (ls -a)

Services

  • cronrunningstarts at boot
  • sshrunningstarts at boot
  • nginxrunningstarts at boot

Check

Safe habit, or risky?

Swipe right for good, left for needs work. Or use the buttons.

1 / 4

Run ls first. Then rm exactly what you saw.

Run ls first. Then rm exactly what you saw.

Try it

The 2025 menus are not needed. Delete the old folder and everything inside: rm -r old.

You are you in /home/you/kedai. 7 things here. Services: cron running, ssh running, nginx running.

You are hereyou@kedai:~/kedai$

Folder ~/kedai

  • a.tmp (file)-rw-r--r--
  • b.tmp (file)-rw-r--r--
  • counter/ (folder)drwxrwxr-xorders.log
  • kitchen/ (folder)drwxrwxr-xrendang.txt sambal.txt
  • menu/ (folder)drwxrwxr-xdrinks.txt today.txt
  • old/ (folder)drwxrwxr-xmenu-2025.txt prices-2025.txt
  • store/ (folder)drwxrwxr-xstock.txt

+ 1 hidden (ls -a)

Services

  • cronrunningstarts at boot
  • sshrunningstarts at boot
  • nginxrunningstarts at boot

Check

Put the safe delete routine in order.

First step at the top. Put these in order. Use the arrows, or drag.

  • pwd: am I in the right room?
  • rm -r old: delete it
  • ls: check it is gone
  • ls old: what is inside?
  • cp -r old ~/old-backup: only if unsure

You did it!

You can now delete files and folders, carefully, with no undo.

Go deeper (optional)

rmdir old deletes a folder only when it is empty: a gentle choice. rm -i asks before each file on a real machine. -f never asks and hides errors, so treat it like a sharp knife.

Real rep (optional), in a practice folder:

Real mission

  1. mkdir -p trash-test && touch trash-test/a.tmp trash-test/b.tmp
  2. rm -i trash-test/a.tmp
  3. ls trash-test
  4. rm -r trash-test

0 of 4 steps done · Your ticks are saved.