Chapter 02 of 17
Work safely with files
Create, copy, rename, remove, and link files while understanding what each operation changes.
The mental model.
mkdir creates directories; touch creates an empty file or updates an existing file’s timestamp without clearing its content. cp makes a separate copy, mv renames or relocates a directory entry, and rm removes a name. There is usually no terminal recycle bin.
The shell expands an unquoted wildcard before a program runs. *.log matches names in the current directory, not every log on the system. Quote paths with spaces and quote patterns passed to find so that find, rather than the shell, interprets them.
A symbolic link stores a path and can cross filesystems; it breaks if its target is moved. A hard link is another name for the same inode on the same filesystem. Removing one hard link does not remove the data while another link or an open file still references it.
Before a destructive action, inspect pwd, list the target, and use an explicit path. Prefer a private practice directory. On a real system use -- to end option parsing when a filename starts with a hyphen.
Read it. Predict it. Try it.
Before running these commands, predict what each line will change or print. Launch a quest below to open the simulated terminal.
mkdir -p practice/notes
touch practice/notes/day1.txt
cp practice/notes/day1.txt practice/notes/day1.bak
mv practice/notes/day1.txt practice/notes/linux.txt
ls -l practice/notesThe final directory should contain linux.txt and day1.bak. Renaming the original leaves the independent backup intact.
Check your understanding
Explain the why.
Put it into practice.
Complete the exercises, then try the Boss Challenge without hints. Each quest checks its own objectives. You can revisit this chapter at any time.
Make the learning stick.
Close the explanation and describe the main idea in your own words. Change a filename or input and predict the outcome. Tomorrow, repeat a quest without hints. Then apply it in a disposable real Linux environment.
Open the real-system labs →