Shell

Important commands, shell in general.

Command

Description

script

Creates a typescript of the terminal session.

which <command>

Search for the command <command> in the current directory and display where it was found.

history 20

Display the last 20 commands that were entered.

!<num>

Execute the command <num> again from the history.

<command1>; <command2>

Execute command 1 followed by command 2.

<command1> && <command2>

Execute <command1>, followed by <command2>, but only if <command1> was successful ($? = 0).

<command1> | <command2>

Redirect output of <command1> to input of <command2>.

<command> >&out.txt

Send both the standard output and the error output of a command to the file out.txt.

printenv

Display all environment variables.

echo $PATH

Display individual environment variable "PATH".

setenv <variable> "value" [csh]

Sets environment variable <variable>.

unsetenv <variable> [csh]

Removes environment variable <variable>.

^C (Ctrl-C)

Terminate current command.

^U (Ctrl-U)

Delete up to the beginning of the line.

reset

Reset terminal settings.

exit

logout

Exit shell.

Important commands, job control.

Command

Description

^C (Ctrl-C)

Terminate current foreground process.

^Z (Ctrl-Z)

Suspend current foreground process. Creates a suspended job.

jobs

List jobs under this shell.

kill %<num>

Terminate the job with the number <num>.

fg

fg %<num>

Restart suspended process in the foreground.

bg

bg %<num>

Restart suspended process in the background.

<command> &

Start the command as a background job.