linuxjourney

cd (Change Directory)

Lesson Content

Now that you know where you are, let’s see if we can move around the filesystem a bit. Remember we’ll need to navigate our way using paths. There are two different ways to specify a path, with absolute and relative paths.

Now that you know how paths work, we just need something to help us change to the directory we want to. Luckily, we have cd or “change directory” to do that.

$ cd /home/pete/Pictures

So now I’ve changed my directory location to /home/pete/Pictures.

Now from this directory I have a folder inside called Hawaii, I can navigate to that folder with:

$ cd Hawaii

Notice how I just used the name of the folder? It’s because I was already in /home/pete/Pictures.

It can get pretty tiring navigating with absolute and relative paths all the time, luckily there are some shortcuts to help you out.

$ cd .
$ cd ..
$ cd ~
$ cd -

Give them a try!

Exercise

  1. Run the cd command without any flags, where does it take you?

Quiz Question

If you are in /home/pete/Pictures and wanted to go to /home/pete, what’s a good shortcut to use?

Quiz Answer cd ..

ls (List Directory)–>