Moving around your file system (Absolute and relative paths)Follow @ggarron
Beside the captain in a ship, the next most important guy is the navigator, because is always important to know where you are in the sea, also in your Linux File System you need to know where you are and how to get where you want to:
This is done with some few commands, where some of the most used are
ls, pwd, cd
Knowing where you are
pwd shows you where you are in the directory structure, just type:
And you will have an output like this.
Which means you are in the subdirectory 1024, which is in go2linux subdirectory which is in borrar subdirectory which is Desktop subdirectory which is in ggarron subdirectory and that one is in home and finally home is in the root of the file system.
Listing the contents of the directory
The ls command is going the help us doing this, these are some of its basic options.
Will list recursively the content of the directory where you are.
Will list the content of the current directory, showing you more info than usual like the size, date of the the files.
Navigating in your File System
Once you know where you are, you can start moving.
cd "Change directory" is the command we will use to do this, now we also need to understand absolute paths and relative paths.
Absolute paths are those that you specify from the root, and relative start from where you are at that time.
We are in: /home/ggarron/Desktop/borrar/go2linux/1024
Now lets move to /home/ggarron
cd /home/ggarron pwd /home/ggarron
That is absolute path, as you are specifying it from the root.
Now go back again to where we start.
cd Desktop/borrar/go2linux/1024 pwd /home/ggarron/Desktop/borrar/go2linux/1024
We are again at our start point, using relative paths, we can do the same using absolute paths.
cd /home/ggarron pwd /home/ggaron cd /home/ggarron/Desktop/borrar/go2linux/1024 pwd /home/ggarron/Desktop/borrar/go2linux/1024
As you can see both work the same but it is faster to use relative paths, specially with long paths.
Another way to use relative paths, is to go down and up again in the structure in only one command.
Lets suppose we have this:
cd /home/ggarron/Desktop/go2linux ls 1024 1600 640 800
No lets do this:
cd 1024 pwd /home/ggarron/Desktop/borrar/go2linux/1024 cd ../640 pwd /home/ggarron/Desktop/borrar/go2linux/640
As you may see, we have descended one level and then go up one level again to another directory, we can even go down more than one level.
cd ../../firefox/ pwd cd ../../firefox/
As you can see the use of cd, with relative paths, makes it easy to navigate our file system.
Also, it is important to know that if you enter
With no options or arguments, you will go directly to you home directory.
You may want to check.