Next: Learning by doing
Up: The Shell and Command
Previous: The Shell and Command
- shells: bash
(GUBI)
- what is it?
- text front end alternative to GUI
- program runner
- resources
features (ALAN) There are some extra
concepts that are important to understand how Linux works, and to
effectively use the shell.
- A single directory tree: no device names
- In the Windows world
each device has a letter identification. So it is common to have the
main hard disk under C:, the cd-rom driver under D: and so on. The
complete address of a file is something like
``C:My Documents
Research
thesis.doc''. Linux takes a different
approach. There are no device letters, in fact the user is unaware
of the actual location of his/her files. All directories and files
are under a single root directory. The structure of the directory
tree is controlled by the administrator.The complete address of any
file at the root directory, for example:
``/home/employee1/Research/thesis.doc''. This has many advantages.
In particular, users can be spared of any changes in the system's
device. for example, if a project turns out to use lots of disk
space, we can buy a new hard disk and assign to this new disk the
home directory of the project, copying all the old information into
the new disk.
- The PATH environment variable: finding programs
- As in Windows,
programs can be installed in any directory in Linux. However, in
Windows programs not installed in specific folders can only be
called if you locate the folder and click in the program icon. In
the linux bash shell, you can tell the system which directories can
contain programs. When the user type a command the system
automatically searches in the directories specified. The places
where bash looks for programs are stored in the PATH. In all linux
installation some directories are already part of the path. These
are generally /usr/bin and /usr/local/bin. Almost all standard Linux
applications are located in these two directories. However, any user
can add new directories to his/her path and run other programs
without having to search for them. You can even download a new
version of a program in the system and run your version by default.
You only have to include the directory where you stored the program
in the path BEFORE the system directories.
- auto completion
- Another nice feature of the bash shell is
auto-completion. Is is normally very tiresome to type complete file
addresses or even program names. The bash shell has a special feature
called ``auto completion'': when the user starts typing and presses
the
<TAB> key, the systems tries to complete the typing. If
it is a program name (first word to be typed), bash searches the
directories in the path to find which programs start with the
letters typed. Otherwise bash looks in the partial path specified
by the user to search for completions. If there is only one
completion, pressing the tab key will cause the appropriate word to
appear, if there is more than one completion, a sound will be
emitted. Pressing <TAB> the second time will cause all
possible completions to appear.
- job control: fg, bg, kill
- When using command line, it is
important to understand the concept of ``Process''. A process is a
program running. There can be many processes running the same
program (for example, when you click a the Windows explorer icon in
Windows). A processes can be in two states: running and suspended. When a process is suspended no work is
performed and no work is lost. A running process just executes the
program tasks normally. Processes can be killed, that is, the
user can determine that the processing will end (this is equivalent
to click in the X icon of a window).
- history
- The shell maintains a list of all the commands that the
user has typed. This list is called the ``history''.
- data flow (STDIN, STDOUT, PIPES)
- Linux programs, by default,
get input from the keyboard and output data to the screen. The
keyboard is the Standard Input, or STDIN, and the screen is
the Standard Output, or STDOUT. All basic shell commands use
this principle. A nice feature of command line interactions is that
you can have the output of a program in STDOUT be fed directly to
the STDIN of another program, creating a unix Pipe.. For
example, suppose you have a program that reads words and outputs
synonyms for those words, and a program that reads words and counts
the total number of words read. If you connect the two programs
together, you can type words, and have a final count of the total
number of synonyms. HORRIVEL!!!
- protection - chmod
- Falar direto no learning by doing.
- wrap up
-
Next: Learning by doing
Up: The Shell and Command
Previous: The Shell and Command
gubi
2006-01-18