Basic Linux Navigation
Now we need to talk about basic folder navigation in the Linux operating system. This is slightly different from Microsoft Windows. However, the funny thing is it looks close enough to Windows that when things do not work right, people have the urge to want to pick up their computer and throw it out the window.
Take the above diagram for example. In Linux, you also have the cd command. Just like in Windows, the cd command stands for change directory. If you want to go to a different directory or folder, you type in cd. If you are in a folder, let us say you are in the var folder in our illustration, and you want to go to a folder within the var folder, which in this case is the abc folder, all you need to do is type in the command below:
$ cd abc
So, that is cd, a space, and then the name of the folder that you want to go to. That will drop you in the folder that you are trying to go into. Now, the problem is, people in the Windows world are used to following the cd command with a forward slash symbol. If we were to apply this in our previous command, it will look like the one below:
$ cd /abc
What Linux does in this case is it interprets the forward slash symbol as the root folder. Linux will think that you want to change to the root folder, and then look for the abc folder within the root folder. Of course, once Linux executes this command, it will not be able to find an existing abc folder since in actuality, the abc folder is located in the var folder. That is where you have to be extremely careful.
This is one reason why a lot of Linux administrators always type in the full path towherever they are trying to go, no matter where they are at. If a Linux administrator is trying to go in and change something in the abc folder, they will just type in the command below:
$ cd /etc/var/abc
Linux is finicky about this whole change directory syntax. As we have mentioned before as well, capitalization matters in Linux. If you are trying to reach a folder whose name is written in all lowercase, and you type the folder in all capital letters, Linux will not be able to find it; it will say that the directory cannot be found.
All of this is important for you to understand. It can be extremely frustrating if you do not grasp it.
So, the first thing you want to do when navigating files and folders in Linux is make sure that you are in the root directory. To do this, you must type the command below:
$ cd /
That is cd, a space, and then a forward slash. This is automatically bring you to do the root directory if you are not already there. Now the next logical thing to do would be to see what folders are within the root folder itself. To do this, you must type the command below:
$ ls
The ls, or list command will list all the files and folders within a particular directory—root, in this case.
As you can see after typing in the ls command, Linux will now show you all the folders that are within in the root directory. You can see lots of folders here like the bin, dev, opt, sbin, sys, var, boot, etc lib, and so forth.
Now, let’s say we want to go to inside the etc folder. All you need to do is type in the command below:
$ cd etc
The command above will automatically drop you inside the etc folder. If you look beside the blinking cursor of the command prompt, it will say /etc$. That is the main indication that you are indeed inside the actual folder that you want to go into. If you do the ls command again, it will show you all the files within the etc folder.
In order to go back to the root folder, all you need to do is type:
$ cd /
This will automatically return you to the root directory no matter how deep you are within the folders.
Now let’s say you want to go back to the etc folder. But this time, instead of typing etc in all lowercase, you typed it in all uppercase.
As you can see, Linux will not be able to find the directory with an uppercase ETC. Why? Because Linux cares about capitalization. Uppercase letters are different from lower case letters in the Linux world. Basically, that is all there is to it in Linux basic navigation.