Quick reference guide Scientific Linux for DESY

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 configured for maximum comfort. If the commands differ in the shells, only zsh and tcsh are explicitly mentioned.

The login shell is configured in the central registry, it cannot be modified by users. Change requests should be sent by email to the user consulting office.

. file [arg[s]] SA
Read commands from file and execute them in the current shell environment. In tcsh source has to be used instead.  
End of file character, usually exits the shell  
Clear the terminal screen, does also redraw the screen in many applications.  
alias [name[=value]] (zsh) S
alias [name[ value]] (tcsh)  
List all aliases, the alias name or define alias name to have given value  
basename filename [suffix]
Strip directory (and optionally suffix) from filename Documentation
bash [options] [file]
GNU bourne-again shell. Start a new shell or execute commands in file under the control of the shell. When called with option -x it prints commands as they are executed, with -noprofile startup or initialization files are skipped. Documentation
bc [-l] f
Calculator that supports arbitrary precision numbers. Use option -l to do real arithmetics. Simple calculations can also be performed in the shell, e.g.: echo ((0x15 + 3*7)). A graphical alternative {xcalc} does exist as well.  
Clear the terminal screen  
csh [options] [file]
On Linux identical to tcsh. For differences to tcsh see man tcsh  
dirname filename
Strip non-directory suffix from filename Documentation
echo [-n] [string[s]] S
Display string[s] on the standard output. Suppress the newline at the end with -n. In zsh print can also be used. Documentation
env [-] [-u variable] [variable=value] [command]
Run command in a modified or empty (-) environment, setting variable to value or removing a variable (-u) from the environment. Without arguments the environment is printed. Without command the environment is modified. Documentation
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. For tcsh see setenv.  
expr expression
Evaluate expressions. Arguments and operators have to be separated by white space. Some operators need to be escaped to prevent shell expansion.
Example: increment a shell variable: i=`expr i + 1`
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 [n] S
Print entries from the command history. Print the n most recent entries (in zsh use -n). Manipulate the history 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. See also module.  
ksh [options] [file]
Korn shell, a command interpreter and programming language. Good for writing scripts. For differences to zsh see man zsh.  
module [options] [subcommand [args]]
Allows to dynamically modify the user’s environment. A short help is available with the subcommand help, a list of available modules with avail and the list of active (loaded) modules with list.  
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]]
Print all or part of the environment variables Documentation
rehash S
Rebuild the hash table of commands in the command PATH. Useful after a change of the PATH environment variable.  
Print a command to set COLUMNS and LINES to current window size. Useful to adjust the (xterm) window size using 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]
(Bourne) shell. It is the only shell guaranteed to exist on all UNIX systems. It is mainly used to write shell scripts. On Linux systems the same as bash.  
sleep time
Suspend execution for a specified amount of time seconds Documentation
source file [arg[s]] (not ksh) S
Read commands from file and execute them in the current shell environment  
stty[-a] [-g] [settings]
Change or print terminal line settings. List all settings with option -a. Settings with a leading - (minus) are off. Most useful for resetting the terminal characteristics with stty sane Documentation
tcsh [options] [file]
C shell with file name completion and command line editing. Start a shell or 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] S
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 -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).  
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]
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