With the terminal you may very easily navigate your computer directories and even access the Internet. In fact it is easier to work with folders and files with the terminal than it is with a Graphical User Interface (GUI - a program where you click the folders in order to open them).Let's learn the basics of navigating using the terminal.
First comes first. For you to navigate, you should know where you are. Have you ever noticed that text that start each new line in the terminal and you cannot delete? That is the identification of the current user, of the current computer and of the current folder. This is very important because, as you'll learn, using the terminal you can actually use different users, different computers and, of course, different folders.
Let's go for an example: say the user is "joe", the computer name (the
computer name is set during installation process) is "compute" and that he is
now in the folder
/home/jose/Documents/. Terninal will look like
The tilde symbol "~" means the home folder of the current
current user. If the user is in the folder
will look like this:
When you're using terminal and want to know where you are, simply check the path after the colon.
The dollar symbol $ indicates you are using a regular user. The hash symbol #, would indicate you are using the super user, or "root". So, when you find a tutorial saying something like this:
root@computer:/home/user/# apt-get install hex-a-hop
Notice the hash symbol! It means this command must be used as root. You can use the sudo program to act as super user (sudo = su [super user] do [act, do something]).
user@computer:~/$ sudo apt-get install hex-a-hop
There are some basic commands to navigate using the terminal. Here are some of them:cd : used to enter a directory, examples: access the "Documents" folder that is inside the current folder:
user@computer:~/$ cd Documents
Access the same folder using its full path. Notice that when you place a "/" before the first folder you mean that you are indicating the full path, the path from the root directory.
user@computer:~/$ cd /home/user/Documents
Access the "texts" folder inside Documents folder which is in the current folder. :
user@computer:~/$ cd Documents/texts
Notice you don't need to enter a folder first to enter an inner folder afterwards. You may simply give the path.
Leave the current folder and go back to home:
Go back to the the parent directory of the current directory:
Go back two parent directories:
Check the content of the directory. It would be no use navigate if you cannot see what is in the folder. Here comes the ls command (ls = list)
You may list the content of other folders as well, giving ls the path of the folder you want to list. This will not change your current directory, but will show the contents of the other folder:
You can list contents and their permissions.
You can also filter the results of your listing. Sometimes there are simply way too much results for you to check manually. Simply give a part of the name you want to find and use these two special chars:
|*||means any characters, any number of them|
|?||means any character, only one|
Let's go to some examples:
List only files with the extension ".odt"
List only files with the name "important" with any extension:
How to access folders with composed names (with spaces)?
Have you noticed that when you try to use the command
cd with a folder that has a space in its name it doesn't work?
Terminal answers that "important" folder does not exist. The space indicates, in terminal, that the name is over. We need to tell terminal that this time the space will not mean the end of the name. Use a "\" before the space to tell that the next space means only a space:
I am lost! Where am I?
If the terminal you are using is not showing the path you are in, you can use the command pwd (Present Working Directory) to find out where you are:
Terminal will show you the current folder.
These commands may be very useful for a basic navigation. Get used to them and then try to learn some more advanced techniques. You will soon realize terminal will make your life a lot easier.