cd: change which folder you're standing in
cd stands for "change directory." It's how you move. You give it a
destination, it walks you there, and the next pwd proves it.
Going down into a folder
To step into a folder that ls showed you, type cd and the folder
name:
cd Documents
Now you're standing in Documents. Run pwd to confirm, run ls to
see what's in here. This is the loop: cd to move, pwd and ls to
get your bearings in the new spot.
Going back up
To go up one level, to the parent of where you are, use the ..
shortcut from the tree lesson:
cd ..
If you were in Documents, you're now back in your home folder. ..
always means "up one." You can even chain it: cd ../.. goes up two
levels in one move.
The two get-home shortcuts
When you're deep in the tree and want to bail out to the top of your personal files, you have two options that do the same thing:
cd ~
or just cd with nothing after it:
cd
Both drop you back at your home folder. cd on its own is the panic
button. Lost, confused, no idea where you are? Type cd, press enter,
and you're home. Then ls and start again.
Long way and short way
You can also give cd a full path to jump straight somewhere:
cd ~/Documents/taxes
That goes from wherever you are directly to the taxes folder in one
line, instead of three separate cd steps. Same destination, fewer
moves. Both ways are correct. Use whichever you can hold in your head.
Try it now: cd into a folder, run pwd, run ls, then cd .. back
out. Do that two or three times. That's moving around. That's the
lesson.
cd: change which folder you're standing in
cd stands for "change directory." It's how you move. You give it a
destination, it walks you there, and the next pwd proves it.
Going down into a folder
To step into a folder that ls showed you, type cd and the folder
name:
cd Documents
Now you're standing in Documents. Run pwd to confirm, run ls to
see what's in here. This is the loop: cd to move, pwd and ls to
get your bearings in the new spot.
Going back up
To go up one level, to the parent of where you are, use the ..
shortcut from the tree lesson:
cd ..
If you were in Documents, you're now back in your home folder. ..
always means "up one." You can even chain it: cd ../.. goes up two
levels in one move.
The two get-home shortcuts
When you're deep in the tree and want to bail out to the top of your personal files, you have two options that do the same thing:
cd ~
or just cd with nothing after it:
cd
Both drop you back at your home folder. cd on its own is the panic
button. Lost, confused, no idea where you are? Type cd, press enter,
and you're home. Then ls and start again.
Long way and short way
You can also give cd a full path to jump straight somewhere:
cd ~/Documents/taxes
That goes from wherever you are directly to the taxes folder in one
line, instead of three separate cd steps. Same destination, fewer
moves. Both ways are correct. Use whichever you can hold in your head.
Try it now: cd into a folder, run pwd, run ls, then cd .. back
out. Do that two or three times. That's moving around. That's the
lesson.