People new to Linux tend to react to any reference of the Linux shell terminal with fright. But there is nothing scary about our beloved shell terminal, or what we most commonly call the command-line interface (CLI) or simple the command-line. It is a very powerful place to interact with Linux. Every operating system has its own “command-line,” including Windows.
Unlike a graphical user interface where the operating system is directed to perform varied tasks via point-and-click operations, the Linux shell terminal lets you do the same by typing commands made up of a line of text. That is how we got the “command-line.” The shell just interprets the commands that you type.
The main purpose of this article is to show users new to Linux how to access a shell terminal, and how to open and edit files from its interface. Keep in mind that you do not need to know how to use a shell terminal to use any Linux desktop distribution, but there are occasions when you will need to edit certain configuration files that do not have a graphical management interface.
So I will take you step-by-step on how to become familiar with the command line. Just very basic stuff, nothing fancy. Keep in mind that there are many shells in Linux and other UNIX-like operating systems, but you do not need to know all of them. It is sufficient to know that the default shell in Linux is called Bash, short for Bourne-Again SHell. The name has nothing to do with a religious group or sect, just derived from the name of a very important geek in our history.
You will always find an entry for the shell terminal in the menu of any distribution you are using, and depending on the distribution, it could listed as a Terminal or Konsole. If you are using the latest edition of Ubuntu, follow these steps to launch it:
Press the Super key on the keyboard (that is the key with the Windows logo on it. If you are lucky enough to have a keyboard without that logo, it is the key between the Ctrl and Alt keys). Or just use the mouse to click on the Ubuntu log on the top-left corner of the desktop. In the search box that appears, type “term” or “terminal.” The Terminal should be the first result returned. Click on it to launch it.
Now that you have found and started it, the image below shows what you should have on your desktop. sun@hu:~$ is called the prompt. sun is the username; hu is the hostname, or the name, of the computer; “~” (tilde) represents your home directory; the dollar sign indicates a non-administrative user. Note that if you are not in your home directory, “~” will be changed to reflect the correct present working directory.
Because Ubuntu uses the sudo command to grant administrative privileges, when attempting to edit a file that requires such a privilege, the right way to access the file is to use the gksudo command. gksudo is the GTK+ frontend for sudo. gedit is a graphical text editor. If you from Windows, this is just like Notepad, only much nicer.
If your distribution is powered by the K Desktop Environment (KDE), with the Kickoff Menu, you can find and start the terminal by clicking on the menu’s icon and typing “term” or “terminal” in the search box. One of the results should listed as Terminal or Konsole. Click to start it. If you are using a KDE menu that does not have a search box, the terminal is most likely going to be under the Accessories menu category.
The terminal you see on your desktop should be just like the one shown below. The components of the prompt is the same as that of Ubuntu or any distribution using the GNOME desktop environment.
If your distribution uses the traditional root account system, where there is a separate root user with a password, besides the regular user(s), and you have to edit a system-wide file, one that requires authentication as an administrator, you will first have to type the su command. When you type su (switch user), the system will prompt you for the password of the root or superuser account. After you authenticate successfully, you may then open the file you wish to edit with a text editor. # (octothorpe) indicates that you are working as the root user.
This screen shot is used to explain a few basic commands that you may use to navigate the terminal. When you first launch a shell terminal, you will be in your home directory. You can verify that by typing the pwd (present working directory) command. It will always return whatever working directory you are in. If you need to edit a file that is not in your present working directory, and you want to switch or change to the file’s directory, just type the cd (change directory) command followed by the directory you want to change into. As shown in this image (see number 2), I changed into the /etc/default directory. Typing the ls command by itself will list the files in the present working directory. Finally, you can open the file without appending the directory it is in before the name of the file.