Lessons · Terminal · moving between folders
Moving around
cd folder moves you into a folder. cd .. goes up one. cd on its own goes home. cd - goes back to where you were before.
Hone is a place to practise programming. This is one of its lessons, written out in full and free to read without an account.
What it is for
Projects are trees of folders and every command runs from where you stand. Moving well is most of the skill.
How to think about it
Say the move out loud: into notes, up one, back to the last place. Then pwd if in any doubt.
Worked example
mkdir -p demo/src demo/docs && cd demoA project with two folders.
cd srcInto src.
pwdEnds in /demo/src.
cd ..Up one.
pwdEnds in /demo.
cd docsInto docs.
cd -Back to the previous folder, and it prints where you landed: /demo.
Your turn
Go up one folder.
cd
Try it at a real prompt
The trap
cd with a path that has a space in it, unquoted. cd my notes tries to enter 'my' and complains about 'notes'.
Practise moving between folders on HoneA question on it now, a coding challenge where there is one, and it is remembered for review. Free, no email needed.