Accessing the Linux command line is quite simple. I’ll describe the process as it is on a Ubuntu system but only because Ubuntu has the most market share of the Linux distros today. The concepts here carry over all most if not all other Linux distributions. One other thing I should point out is that the command line is sometimes referred to as the “console” or “terminal” and I may use those terms from time to time.
There are times that you’ll need to use the command line in order to get something done because there won’t be an appropriate GUI tool available or a GUI tool that is available doesn’t have a needed option. In these cases you can access the command line to get the job done.
In general, there are basically three ways to access the command line in any given Linux distribution. Two of them are “local” meaning you must be sitting at the machine and the other one is to remotely access your machine using SSH or “Secure SHell”. I’ll discuss using SSH in a later article.
As I said earlier, there are two ways to access the command line in most Linux distributions. Ubuntu itself uses a mostly vanilla install of GNOME as it’s default desktop meaning it looks and behaves mostly as it would if you had compiled the software yourself. The menus are laid out almost exactly the same.
GNOME provides a software application called Terminal which gives you access to the command line. You’ll find this program under Applications->Accessories->Terminal. Starting this program will bring up a mostly white screen (by default anyway) that contains the following
dustin@mythtv:~$
This is known as the command prompt. This prompt has a certain format and it shows you who you are, what machine you’re on and where you are on that machine. The first part is my username on the system, simly dustin. After the @ symbol is the machine name which in my case is mythtv since that is this computer’s primary purpose. Next is the colon followed by the tilde. The colon is simply a separator where as the tilde means I am in my home directory. This will change depending on what directory you are in. The dollar sign marks the end of the command prompt and little more (it does also signify that I’m a normal user, but this isn’t necessarily universal).
The other method for accessing the command line is to access the system console (which is truly called a virtual console, but the reason isn’t important). The system console exists “outside” of the GUI and in fact, the GUI is running “on top of” the console, much the same was as Windows 3.1 ran on top of DOS. To access the console, press ctrl+alt+ a number such as 1. By default, Ubuntu provides 6 consoles so you can substitute 1 for any number up to 6. This screen will provide a prompt for you to login. This is because the console exists as a separate process outside of your desktop. Remember that Linux is a true multi-user operating system and is designed to allow multiple users to use the system at the same time. On this screen, you would enter the same username and password that you use to log in to the desktop.
You are now ready to interact with the system. You can get started by trying out some of the most basic of commands such as ‘ls’ (without the quotes) followed by pressing the enter key. This command will list out the contents of the current directory.
dustin@mythtv:~$ ls
Desktop fixsound run_mtd vmware
Examples nautilus-debug-log.txt runmythfrontend
Firefox_wallpaper.png Pics settings
dustin@mythtv:~$
Please excuse the formatting of the output, it’s much cleaner in the actual terminal window.
To change directories you use the ‘cd’ command followed by where you want to go. Be sure to separate the ‘cd’ command from where you want to go with a space. For example, if you want to go one directory higher you can type ‘cd ..’ and you’ll be changed to the new directory.
dustin@mythtv:~$ cd ..
dustin@mythtv:/home$ ls
dustin mysql.sql mythtv
dustin@mythtv:/home$
To enter the dustin directory you would type ‘cd dustin’ and press enter.
‘cd’ and ‘ls’ are not the only commands available to you, not by a long shot. For an extensive list of commands and what they do click on over to http://www.ss64.com/bash/.
Next time I’ll talk little bit about how the filesystem is designed as how to check some performance stats on your machine.