Its really calming to look to the ocean, the waves and all that vastness… but it’s even cooler if you grab a surfboard and go have phun fun, right? It’s the same with the Linux filesystem! You can know the theory and the preparation behind it, but if you don’t have a surfboard, you are just a spectator!
You need to master the basic tools to move around, to, in a simple, direct way, see where you are on your system, and where to go from there. I’m not going to talk about file manipulation, nor inspection, just how to move around…!
Let’s start! How to know where you are? Very quickly, just type pwd (print working directory); this gives you the current working directory. Quick and painless, as it should be! In this case I know that I’m seating at my home directory.

In case you get lost on the ocean, this command is a life savior, because it tells you exactly where you are.
Now lets move around in the system: type cd /etc, this will take you to the /etc directory. Not so hard right? Now, if I asked you to go back home (/home/mgarces), your first answer should be cd /home/mgarces, am I right? Well, you did get it, but there is a fast way… just type cd, and this will always take you to your home directory. The rule is: if you are <user> and type cd with no arguments, it will take you back to /home/<user>, except if you are user root, in this case you are taken to the /root directory. There is also another cool way to go home: you can make a cd $HOME or a cd ~, the results are pretty the same. This is very useful, because as you later will learn, its better for writing scripts, because you use the system variable $HOME, so you can adapt any kind of script, to any kind of user… but lets no get ahead of ourselves.
In Linux you have absolute paths and relative paths. If, you are in /home, and want to go to /home/example, you could either use the absolute path, which is cd /home/example or, just type cd example (you are already in the /home directory) because the of the example subdirectory is inside /home directory.
One last thing on moving. If you’r sitting in any directory (and as you remember from the FHS tutorial), you have a . and a .. corresponding to the current directory and to the parent directory, so to go up, for example, from /home/mgarces to /home, you do a cd .., and this will take you there! Advanced use for this is, for example, if you are in /home1/user1/ and want to go to /home2/user2, is just a simple command: cd ../../home2/user2. Go up 2 levels, and from there, absolute paths all the way in! =)
Now you have the basics to go from point A to point B, and also to know where you are, inside your filesystem. Next stop: listing directories!
   Share This


0 comments ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment