This tutorial is supposed to show new Linux users how to handle Linux without having to browse through your desktop to edit files. The core commands to do this are the same on every Linux distribution, however there is a large variety of commands that differ from distribution to distribution, as does the install command.
This document comes without warranty of any kind!
1 Preliminary Note
While Terminal may not always be helpful on other operating systems, it is a powerful tool on Linux. You can run every application you will need on it, install packages and manage your files and folders by commands. However it is to be handled with care, since unknown commands or commands whose causes are not absolutely clear to you can cause a great deal of trouble and serious damage. Try to prevent using these or backup your system before you do. The screenshots of this tutorial are taken on Linux Mint 11.
Terminal is the tool where system commands can be used. You can find it on Menu > Terminal . On startup you will be logged in as the current user. For some commands it is necessary to be logged in as root. For this, there is a special command that grants you permissions of root for the whole session or for single commands. Be cautious acting as root though, since some system files need the root-user to be edited. Needing administrative rights to edit files usually means that it can be dangerous to do so if one is not familiar with the tasks of the file.
You will notice the symbols in the command line just before the cursor position. The wave is the symbol for the current users home folder. On startup, this is the directory Terminal is pointing at. You are going to learn how to change it soon.
3 Creating, Moving And Deleting Files And Directories
To start with, we are going to create a text file via Terminal. As said before, Terminal is right now pointing at your home directory. This is why the created file will appear there. To create a text file, we are going to use the following command:
This will create an empty text file named test.txt. However, we are not happy with the file just being placed in our home directory. That is why we create another directory and move our just created empty file there. To create a new directory in our current one, we use:
mkdir stands for “make directory” and followed by a name it will create a new empty directory with the chosen name (here: fortesting) in our current directory. Since we now have a folder to place our text file in, we proceed by moving it there. To do that, we use following command:
mv ./test.txt ./fortesting
The mv command ist used to rename or move files from one to another directory. You may notice the dots before each pathname. They indicate that the path starts in your current directory so in our case, the dot stands for the home direcory. There is also the option to place two dots in a row which indicates that the path starts from the directory above the current one. So what we are doing is to move the test.txt from the home directory to fortesting, which also is a folder inside the home directory. mv can also be used to rename single files. It works the same way as moving them. Let us rename our test.txt:
mv ./fortesting/test.txt ./fortesting/bla.txt
To delete our created file, we use the rm (remove) command.
To delete an empty directory such as the one we just emptied we need another command:
In this case we used the rmdir command which removes an empty directory (dir for directory). Notice that I did not place a dot before the path of the directory! If you are in the same directory as the objects you are working with, you can just enter their name as path.
4 Changing Directories And Copying Files
As mentioned before, the directory paths used in commands are introduced by a dot while acting out of your current directory. Because paths can cover a whole lot of directories if you are managing files deep down your system, it makes sense to change the directory you are acting in sometimes. To do that, we use the following command:
You will notice that the commandline now shows the subdirectory the Terminal is in.
If you introduce directory paths with a single dot, in our example we will now act in the fortesting folder. To act in the folder above, which is now our home folder, we use the double-dot.
To copy the just created file, we use the following command:
cp ../home.txt ../home2.txt
The cp command needs a file to copy as input and a destination to know where to copy targeted file. The name of the copy has to differ from the original one.
5 Learning More About Commands
To learn more about commands you can use, type in:
Replace [command]with the command you want to learn about. Terminal will then give you a manual for the chosen command. This is how it looks like if you chose man itself as [command]: