>_ IzzyLab

Hands-on task

This task is step 6 of the course “First steps in Linux”

Clean up junk without touching anything else

easy~5 min

A build left some junk in /root/project. Delete:

  • all files with the .tmp extension — hidden ones included;
  • the empty directory old.

Everything else must stay: regular files, hidden files, and the data directory with its contents. Hidden files are the ones whose names start with a dot: a plain ls doesn't show them.

What you'll practise:
  • rm
  • rmdir
  • ls -a
  • hidden files
  • name patterns

Topic breakdown

A hidden file in Linux is simply a file whose name starts with a dot: .bashrc, .env, .gitignore. They usually hold settings. ls doesn't show them so they don't get in the way; the -a (all) flag shows everything.

rm deletes files, rmdir deletes empty directories. The shell can fill in names from a pattern: * means "any characters", so rm /tmp/*.log deletes every file ending in .log in /tmp. But * doesn't match a dot at the start of a name — the pattern skips hidden files.

ls -a /tmp/demo        # .  ..  .hidden.log  a.log  b.txt
rm /tmp/demo/*.log     # deletes a.log, .hidden.log stays
rm /tmp/demo/.*.log    # and this pattern is for hidden .log files

The terminal has no trash bin: a deleted file is gone at once. So look first (ls), then delete.

What's checked

  1. No .tmp files left
  2. The old directory deleted
  3. The files you need and the data directory are in place

What it looks like