Moving around: cd
Now that you can look around, it's time to walk around. cd means change directory, and it's the command you'll type more than any other.
You will learn
- The Linux folder tree, and why there's no
C:\ cd,cd ..,cd ~,cd -- Absolute vs relative paths
- Where important files live, including where Rocky and Ubuntu keep their logs
One big upside-down tree
Windows has separate drives like C:\ and D:\. Linux has one single tree that starts at /, called “root.” Everything lives somewhere under it: your files, settings, programs, even USB sticks.
This layout is almost identical on Rocky and Ubuntu. It follows a shared standard, so skills transfer between the two. Lesson 7 tours every one of these folders.
The cd moves
cd Documents # go into Documents (inside where I am) cd .. # go UP one level cd ../.. # go up two levels cd /etc # go to an exact place, starting from the root cd # go home, from anywhere cd ~ # also home cd - # go back to where I just was (like a Back button)
Absolute vs relative paths
A path is directions to a file or folder. There are two kinds:
- Absolute paths start with
/. They're like a full street address:/home/student/Documentsworks from anywhere. - Relative paths don't start with
/. They're like “two doors down”:Documentsonly works if you're standing in/home/student.
Type the first few letters and press Tab. cd Doc + Tab becomes cd Documents/. No typos, and if nothing completes, the thing you're typing probably doesn't exist. If a name has spaces, put quotes around it: cd "My Folder".
Where the logs live
Logs are the system's diary. When something breaks, admins go to /var/log first. This is one place where the families use different file names:
| What's logged | Rocky / RHEL | Ubuntu / Debian |
|---|---|---|
| General system messages | /var/log/messages | /var/log/syslog |
| Logins, sudo, SSH | /var/log/secure | /var/log/auth.log |
| Software installs | /var/log/dnf.log | /var/log/apt/history.log |
| Everything (modern way) | journalctl, the same on both | |
Try it: treasure hunt 🗺️
A treasure is hidden somewhere inside games/maze. Explore with cd and ls, and read any clues you find with cat.
Quick check
1. You're in /home/student/games/maze. Where does cd .. take you?
✓ .. always means one level up.
2. Which of these is an absolute path?
✓ Absolute paths start with / and work from anywhere.
3. On Ubuntu you want to see who logged in over SSH. Which file?
✓ Ubuntu uses auth.log. On Rocky, the same information is in /var/log/secure.