Shell Changing Directories
A directory is another word for a folder. cd moves the shell into a different directory.
Move into a folder
cd docs moves into the docs folder.
cd docs
lsMove to the parent
cd .. moves to the parent folder. The parent is the folder that holds the folder you are in.
cd docs
cd ..
ls photosMove home
cd ~ moves to your home folder. Home is your own folder on the computer.
cd ~Move back
cd - moves back to the last folder.
cd docs
cd -Example
cd docs
ls
cd ..
ls photosKey points
- cd: the command that moves the shell to another folder.
- Use cd .. to move to the parent folder.
- Use cd ~ to move to your home folder.
- Use cd - to move back to the last folder.
In this example, the first line moves into the docs folder. The second line lists it. Then cd .. moves to the parent folder. The last line lists the photos folder.
Note
cd with no name moves to your home folder too.
Try it Yourself
Edit the code, then press Run.
Running is simulated
Exercise
Which command moves to the parent folder?