What do I do if I can't navigate to a certain directory?

Question

I’m supposed to navigate to the /home/ccuser/workspace/blog/2015 directory so I can continue with this exercise, but I navigated somewhere I didn’t mean to. How can I find my bearings and get to where I need to be?

Answer

Always be sure to keep in mind two things when navigating the command line:

  1. Your current location (pwd)
  2. Available directories to cd into (pwd)

This should keep you on track, and is generally just good practice.
But! If you are already ‘lost,’ there’s still hope. In this case, we have a file tree structure handy, which shows you the entire directory structure and should help you find your way around.

Just keep in mind: Using cd .. goes up one level, so if you’re already inside of the ‘jan’ directory, for example, and go up one level, you will then be in the ‘2015’ directory, and will have access to ‘jan’, ‘feb’, and ‘motherboard.txt.’

16 Likes

Why do I keep getting this error message whenever I try this command?
$ cd 2015
bash: cd: 2015: No such file or directory

it means no directory named 2015 exists within the current working directory.

you can use pwd to verify what your current working directory is, and ls to see the files and directories within the current working directory

5 Likes

It means you are in the wrong directory. Imagine you are in a room, and there are 3 doors available. You want to go through the door that is called 2015. But you entered the wrong room, so you can’t go through that door as none of those doors have the name (that door doesn’t exist there).

You have to retrace your steps in the house, for example, by typing ‘cd …’ repeatedly, until you come into the hallway that will lead you towards the right room. By using pwd you can see where you are, and by using the file structure, you can see where you have to go. Then you cd ‘‘directory’’ until you come to the right room that has the door called 2015.

8 Likes

Thank you. This analogy really helped me out, I was stuck for bit in Xubuntu command terminal.

  1. Available directories to cd into (pwd)

Is this a typing error? The tutorial says it should be ls?