Quick Overview of Shell Operation

Quick Overview of Shell Operation

When you log in or otherwise invoke the shell, it checks system variables and the /etc/passwd file to determine who you are and where your login session is supposed to begin. It then searches the system for default configuration files and looks for configuration files in your home directory. Typically, these system files set up a few aliases, do some security checks, configure your prompt, and perform half a dozen other user- and site-specific tasks limited only by your imagination. It then prints out a prompt and waits for you to enter a command.

When you do enter a command, the shell first parses it. It identifies any redirection of standard input, output, and error, any background detachments, looks up any shell variables (e.g., $DBDIR) or aliases (ll) and replaces them with the values they represent. It expands any wildcard arguments (e.g., the "c*" in "ls -l c*") into lists of actual files and concatenates them into argument arrays suitable for passing to an actual command. The line you typed in is stored in whatever history mechanism the shell provides. The shell searches the directories specified in your $PATH system variable for the command you typed in. If it finds it, it constructs a list of arguments composed of that command and any expanded arguments, forks() a copy of itself, and execs() the specified command. When the command finishes executing, control passes back to the shell. It prints out another prompt and the whole process starts over.

graphics/tip.gif

You can display your current environment variables and their values with the command

 

env

 



Linux Desk Reference
Linux Desk Reference (2nd Edition)
ISBN: 0130619892
EAN: 2147483647
Year: 2000
Pages: 174
Authors: Scott Hawkins

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net