Command line access
Sometimes on a Linux system you need to enter Linux commands rather than using a GUI. A Linux Terminal window is similar to a DOS command prompt under Windows. On our KDE desktop, you can reach a list of available terminal programs using Start->Applications->System->Terminal as shown in Figure 17.
Figure 17. Opening a terminal on OpenSUSE with KDE 4
On the Ubuntu system, you can find a terminal window either under Applications->Accessories->Terminal as shown in Figure 18 or under Applications->System->Terminal. On Fedora systems, look under Applications->System Tools->Terminal.
Note: If you right-click (or use the appropriate button if you reconfigured your mouse) the terminal menu choice, you will usually see an option to add this icon to your panel or desktop. Adding it to your panel gives you quick access to a terminal without going through the menus.
Figure 18. KDE shell icon
On the OpenSUSE system, select the Terminal (konsole) choice and you will get a terminal window something like Figure 19. In both Figure 19 and Figure 20, we've included some commands and their output that we'll discuss below.
Figure 19. KDE shell icon
The Ubuntu terminal window will look something like Figure 20.
Figure 20. KDE shell icon
The default appearance of your shell window depends on your
distribution and your choice of desktop. To resize it, you can use the
left mouse button to drag the corners or sides of the window. To
scroll back through the most recent history, you can use the scroll
bar. The command prompt typically ends with a $ character for users
root. Usually the command prompt
will end with a
# character indicating that
the user of this shell is user
root or has
root authority. You can use the up arrow to recall previous commands
and modify them if necessary. You will usually find a Settings or
Terminal menu where you change things like window colors and
Figure 19 and Figure 20 show a few commands and their output:
- Shows who is using this terminal window,
ianin this case.
- Prints the full name of the current working directory, which is
/home/ianin this case. Note that the tilde (~) before the $ in the command prompt shows that the user is currently in his or her home directory.
- Changes the current or working directory. We illustrate changing
to the / (or root) directory and then to the /tmp directory, which
is usually used for storing temporary files. Note that / is the
root of the whole file system, and /root is the home directory of
cdwithout any directory name returns the user to the home directory, and using
cd -returns you to the last directory you were in before the current one. Users other than root will normally have a home directory under /home. For example, /home/ian is my home directory on a system where my id is
ian. Remember that tilde (~) is shorthand for the home directory of the current user. Add the name of a specific user to reference that user's home directory. For example, the home directory for user
iancan also be referenced as
- Without parameters, shows the name of the operating system: Linux.
-aparameter, displays additional information about your system.
- Scans the directories in your
PATHenvironment variable, and shows the full path to an executable program that would be executed if you typed the command at the shell prompt. In this case, we see that the
xclockprogram would be run from /usr/bin/xclock. Note: This application is not always installed in a default Linux installation. It is usually part of a package with a name like xorg-x11-apps, so you may have to find and install the appropriate package to use it.
- Launches a new window on your desktop with a clock. Note the
trailing & on the command, which indicates that the command
processor should return control to the terminal window rather than
wait for the command to finish. Note also that this is the first
such process spawned by this terminal window, and it has a process
PID) of 1774.
- With the
-Toption, displays all processes started by this terminal. On some systems, the default display from the
pscommand includes a process status. See the man pages for details on all possible options and output columns. If the status were displayed in this example, you would see the
bashshell program waiting for input (status
Sfor sleeping) as would be the
pscommand is running and would have status
The output from these commands is shown in the two terminal windows above. A text form from the Ubuntu system is shown in Listing 1.
Listing 1. Ubuntu output from some basic commands
ian@pinguino:~$ whoami ian ian@pinguino:~$ pwd /home/ian ian@pinguino:~$ cd / ian@pinguino:/$ cd /tmp ian@pinguino:/tmp$ uname Linux ian@pinguino:/tmp$ uname -a Linux pinguino 2.6.35-27-generic #48-Ubuntu SMP Tue Feb 22 20:25:29 UTC 2011 i686 GNU/Linux ian@pinguino:/tmp$ which xclock /usr/bin/xclock ian@pinguino:/tmp$ xclock&  2072 ian@pinguino:/tmp$ ps -T PID SPID TTY TIME CMD 2049 2049 pts/1 00:00:00 bash 2072 2072 pts/1 00:00:00 xclock 2073 2073 pts/1 00:00:00 ps ian@pinguino:/tmp$
Some other commands that you might find useful include:
- Displays information about the command named cmd_name.
info infoto find out about the info documentation system.
- Is an interface to the online manual (man) pages about the command
named cmd_name. Some information is in info format, while
some is available only in man page format. Try
man manto find out more about manual pages.