Navigating
Now that we know that Desktop is a directory, let’s move into it.
To change our working directory, we can use the cd
command, followed by the directory’s filepath.
From your home directory (~), try:
cd Desktop/
- Print your work directory with the command we already learned and see if it worked!
What if you want to go back?
The parent’s filepath is represented by .., so running cd ..
will bring you back up a level.
Another couple of handy shortcuts for navigating are ~
and /
.
cd ~
will bring you back to your home directory from anywhere in the file system.cd /
will bring you to your computer's root directory from anywhere in the file system so to navigate to yourDesktop
directory from anywhere, you can typecd ~/Desktop
orcd /Users/{yourname}/Desktop
.
This also works with ls
, or any command that requires a filepath.