Unit 2 · Basic Commands · Lesson 12 of 34
CD
cd
Sadly, ls (from what you've learned so far) only shows you the contents of the directory you're currently in. To actually move around, you use cd (change directory), followed by where you want to go:
[user@linux]$ cd movies
All commands you run work relative to your current path, which is why that's called a Relative Path! You can also refer to directories and files using their Absolute Path, which shows the full location of the file starting all the way from root.
As you may or may not know, you're in your home directory right now!
- Absolute Path → The full, direct path from root, i.e.
/home/user/movies - Relative Path → The partial path relative to your current directory, i.e. if you're inside
/home/user(your home directory), you can usecd moviesinstead ofcd /home/user/movies
Getting back out
Remember those path shortcuts from Path Pandemonium? This is where they come in handy:
Lost? Run pwd to see exactly where you are.
Capture-the-flag challenge
Put the lesson to work on a challenge and submit the flag you find. Create a free account to do this part.
Do this lesson for real
With a free account you get the terminal, the challenges and the checks that go with every lesson in Intro to Linux, and your progress is saved as you go. CyberAcad is a 501(c)(3) nonprofit, so there is nothing to pay.