Linux First Steps
computer software
Linux First Steps Linux First Steps
Linux First Steps   Home | Site Map | About Us | Products | Services | News | Contact Us | Links Linux First Steps
Linux First Steps Linux First Steps

Copyright © 2009

Linux® Bible


Unless you specifically change to another shell, the bash shell is the one you use with most Linux
systems. The bash shell contains most of the powerful features available in other shells. Although
the description in this chapter steps you through many bash shell features, you can learn more
about the bash shell by typing man bash. The sidebar "Getting Help Using the Shell" shows you a
few other ways to learn about using the shell.
Locating Commands
If you know the directory that contains the command you want to run, one way to run it is to type
the full, or absolute, path to that command. For example, you run the
date
command from the
/bin
directory by typing:
$ /bin/date
Of course, this can be inconvenient, especially if the command resides in a directory with a long
path name. The better way is to have commands stored in well-known directories, and then add
those directories to your shell's PATH environment variable. The path consists of a list of directo-
ries that are checked sequentially for the commands you enter. To see your current path, type the
following:
$ echo $PATH
/bin:/usr/bin:/usr/local/bin:/usr/bin/X11:/usr/X11R6/bin:/home/chris/bin
The results show the default path for a regular Linux user. Directories in the path list are separated
by colons. Most user commands that come with Linux are stored in the
/bin
,
/usr/bin
, or
/usr/local/bin
directory. Although many graphical commands (that are used with GUIs) are
contained in
/usr/bin
, there are some special X commands that are in
/usr/bin/X11
and
/usr/X11R6/bin
directories. The last directory shown is the
bin
directory in the user's
home
directory.
If you want to add your own commands or shell scripts, place them in the bin directory
in your home directory (such as
/home/chris/bin for the user named chris). This
directory is automatically added to your path in some Linux systems, although you may need to cre-
ate that directory or add it to your PATH on other Linux systems. So as long as you add the command
to your bin with execute permission (described in the section "Understanding File Permissions" later
in this chapter), you can immediately begin using the command by simply typing the command name
at your shell prompt.
Unlike some other operating systems, Linux does not, by default, check the current directory for
an executable before searching the path. It immediately begins searching the path, and executables
in the current directory are run only if they are in the PATH variable or you give their absolute
address.
If you are the root user, directories containing administrative commands are typically in your path.
These directories include
/sbin
and
/usr/sbin
. (You may need to start your shell with a
-l
or
-login
option to have
/sbin
and
/usr/sbin
added to your PATH.)
TIP
TIP
46
Linux First Steps
Part I