Beginner · 25 minutes · Guided lesson

Files, paths and finding help

Navigate deliberately, quote filenames and distinguish copying from moving.

By the end of this lesson

  • Distinguish absolute and relative paths
  • Copy and rename files without losing the source
  • Locate files and explain your command choices

Your environment: Bash and the named tools in a Linux lab. Minimal distributions may require extra packages. Setup help

Paths describe a location

An absolute path starts with /. A relative path starts from your current directory. The special name . means here and .. means the parent directory. Your home directory is available through $HOME; quote it when combining it with other path components. A space is normally an argument separator, so a filename such as meeting notes.txt must be quoted.

A directory is not a drive letter. Linux attaches filesystems to one directory tree. The /etc tree normally holds system configuration, while your own practice documents belong under your home directory. Use pwd and ls before a command that changes files.

Choose the smallest useful operation

cp makes another copy; mv changes a name or location. Neither creates a version history. A destination can be overwritten, which is why a first exercise uses disposable files. Learn to inspect the result instead of assuming that no output means the intended result happened.

find searches a directory tree. Quoting a pattern such as *.txt leaves interpretation to find instead of allowing the shell to expand it too early. Run man find where documentation is installed, or find --help on GNU systems. Short options and features can differ on BusyBox tools.

See it in context

Worked example

A quoted name stays one argument.

mkdir -p "$HOME/training4linux/paths"
cd "$HOME/training4linux/paths"
printf "%s\n" "Meeting at 10" > "meeting notes.txt"
cp "meeting notes.txt" notes-copy.txt
ls -l

You should see both files. cp has duplicated the content; the original filename with a space still exists.

Your turn

Practical lab

Organise two practice documents, preserve the originals and find the finished copies.

Run commands in your own lab. This website displays instructions; the practice terminal below helps you rehearse the syntax.

1. Prepare your workspace

mkdir -p "$HOME/training4linux/file-lab/source" "$HOME/training4linux/file-lab/review"
cd "$HOME/training4linux/file-lab"
printf "%s\n" "Approved" > "source/meeting notes.txt"
printf "%s\n" "Draft" > source/plan.txt

2. Complete the task

  1. Copy both source files into review, quoting the filename that contains a space.
  2. Rename review/plan.txt to review/final-plan.txt.
  3. List all .txt files below the current directory and check both originals remain.

3. Check your result

  • find returns four .txt files: two originals and two review copies.
  • The reviewed plan is named final-plan.txt; source/plan.txt still exists.
Need a hint?

Use cp for the first step and mv only for the review copy. Quote the find pattern.

Reveal a worked solution

Compare this with your approach after trying the task. More than one valid solution may exist.

cp "source/meeting notes.txt" review/
cp source/plan.txt review/
mv review/plan.txt review/final-plan.txt
find . -type f -name "*.txt"

After the lab: Keep the practice tree, or remove only the individual files you created after checking their paths.

Common mistakes to avoid

  • If a command reports No such file or directory, check pwd and letter case first.
  • Do not add sudo to fix a mistyped path.

Check your understanding

Knowledge check

Answer all 3 questions correctly to pass. Retry as often as you need; your best score is kept.

1. Which is an absolute path?
2. Why quote "meeting notes.txt"?
3. Which operation preserves the source file?

Your lesson progress

Not started · Best score: 0% · Attempts: 0

Practical completion is self-reported. Progress is linked to a private cookie in this browser and stored on the site. Clearing that cookie loses access to it. Manage or erase progress.

Keep the reference close

Further reading