Quick reference guide Linux

Previous Contents Index Next 

3. Shell and the shell environment

Both commands for csh like (csh, tcsh) and Bourne like (sh, ksh, bash and zsh) shells are described. There is a nearly perfect downward compatibility among the shells in a family (from right to left in the parentheses). For shell scripts sh or ksh should be used. At DESY support is given for the interactive use of zsh (and tcsh), which are carefully configured for maximum comfort. If the commands differ in the shells, only zsh and tcsh are explicitly mentioned.

. file [arg[s]] SA
Read commands from file and execute them in the current shell environment. In tcsh aliased to source.  
CTRL-D S
End of file character, usually exits the shell  
alias [name[=value]] (zsh) S
alias [name[ value]] (tcsh)  
List all aliases, the alias name or define alias name to have given value  
bash [options] [file] G
GNU bourne-again shell. Start a new shell or to execute commands in file under the control of the shell. Lots of options, e.g.:
-x print commands as they are executed
-noprofile do not read any startup or initialization files
 
chfn UM
Change user information. Prompts for a new office location, office and home phone numbers. No other field may be changed.  
chsh UM
Change login shell. Prompts for a new shell (an absolute path has to be given).  
csh [options] [file] U
Shell command interpreter with a C-like syntax. Start a new shell or to execute commands in file under the control of the shell. Lots of options, e.g.:
-x print commands as they are executed
 
echo [-n] [arg[s]] US
Display arg[s] on the standard output. Suppress the newline at the end with -n. In zsh print can also be used.  
env [-u name] [name=value] [command] U
Run a command in a modified environment, setting a variable name to value or removing name with -u from the environment. Without arguments the environment is printed. Without command the environment is modified.  
exit [n] S
Exit the shell (with exit code n or the exit code from the last command)  
export [name[=value]] (zsh) S
Include variable name in the environment (by setting it to value). Without arguments the environment is printed.  
function name { statements } (zsh) S
Define a function name as a sequence of statements  
functions [name[s]] S
Print the definition of functions name[s] or of all defined functions  
history [[-]n1] [n2] (zsh) S
history [n] (tcsh)  
Print the entries from the command history. Select a range n1 to n2 or print the n most recent commands (in zsh with -n1). The manipulation of the history is possible with history (tcsh) or fc (zsh).  
ini [-d] [product] PN
Load your environment piece by piece. Without arguments list products that can be selected or (with -d) deselected. Updates environment variables.  
ksh [options] [file] U
Korn shell, a command interpreter and programming language. Start a new shell or to execute commands in file under the control of the shell. Good for writing scripts. On systems, where ksh is missing, it can be made a link to zsh. Lots of options, e.g.:
-x print commands as they are executed
 
print [-n] [arg[s]] (zsh) S
Display arg[s] on the standard output similar to echo-e, but much more flexible (lots of additional options).  
printenv [variable[s]] U
Print all or part of the environment variables  
rehash S
Rebuild the hash table of commands in the command PATH  
resize UP
Print a command to set COLUMNS and LINES to current window size.  
rs A
Set TERMCAP and terminal settings to current xterm window size. Works on some ASCII terminals too. Equivalent to the command eval `resize`  
setenv [name[ value]] (tcsh) AS
Include variable name in the environment (by setting it to value). Without arguments the environment is printed. In zsh emulated by a function.  
sh [options] [file] U
(Bourne) shell. It is the only shell guaranteed to exist on all UNIX systems and therefore mainly used to write shell scripts.  
sleep time U
Suspend execution for a specified amount of time seconds  
source file [arg[s]] (not ksh) S
Read commands from file and execute them in the current shell environment  
stty[-a] [-g] [settings] U
Change or print terminal line settings. List all settings with option -a. Settings with a leading - (minus) are off.  
tcsh [options] [file] PM
Shell command interpreter with a C-like syntax. Start a new shell or to execute commands in file under the control of the shell. Lots of options, e.g.:
-f do not source /.tcshrc
-x print commands as they are executed
 
test [expression] US
Check file types and compare values. Behaves identical to the [ expression ] construct in sh like shells. The following tests are true, if:
-d file is a directory -e file exists -f file is a regular file
-g file is set-gid -k file has sticky bit set -L file is a symlink
-r file is readable -s file is not empty -u file is set-uid
-w file is writable -x file is executable
-t [fd] fd or STDOUT is connected to a terminal
-n string is not empty -z string is empty string is not empty
s1 = s2 (strings) s1 != s2 (strings)
n1 op n2 (numbers), where op is -eq -ne -gt -ge -le -lt

Tests can be negated (!), grouped with (), combined by and (-a) and or (-o)
 
unalias pattern (tcsh) S
Removes aliases whose names match pattern. (unalias * removes all aliases)  
unalias [-m] name[s] (zsh) S
Removes the alias definition for name[s] or with -m removes aliases whose names match name[s]. (unalias -m * removes all aliases). Use \name to ignore the alias definition for name temporarily.  
unfunction [-m] name[s] (zsh) S
Removes the function definition for name[s] or whose names match pattern (with -m). unfunction -m * removes all function definitions  
zsh [options] [file] PM
The Z shell. Start a new shell or to execute commands in file under the control of the shell. Lots of options, e.g.:
-f do source only the /etc/zshenv initialization file on startup
-x print commands as they are executed
 

Previous Contents Index Next