Wartburg College
Linux Computation Lab

Using Linux Overview


[Shell Selection] [Shell Features] [Environment Vars] [Jobs] [Files] [Essentials] 

Selecting a Shell

To some extent, the "feel" of interacting with a Unix system depends on the command interpreter or "shell" that you are using. Different Unix systems have different shells, and users can often select among a number of different shells to suit their own tastes.

The most commonly used shell in the Linux world is "bash".  It is an enhanced version of a traditional shell known as the Bourne shell.  Bash is the "Bourne-again shell".  Some other common shells are based on the original "C" shell (csh).

Shell Features (tcsh and bash)

Command recall.
You can cycle through previous commands using the up and down arrows.
Command/filename completion.
If you type the first few characters of a command or file/directory name and then press the tab key, the shell will attempt to complete the command or name. If there is more than one valid completion, the shell will complete the command up to the ambiguity. Pressing tab again will show the possible completions.
Filename wildcards.
You can specify a "set" of files using "*" to represent a sequence of characters. For example, "foo*" matches all the files starting with "foo".

Environment Variables

Environment variables are are often used in Unix to set general properties of the system. For example the variable PATH determines what directories will be searched when trying to lookup a command. DISPLAY determines the machine on which windows will be displayed when using X, the Unix graphical interface. Some useful commands:
echo $<variable>
Display the contents of the variable. Example: "echo $PATH"
setenv <variable> <value> (c-shells only)
Set the value of a variable. To add a new directory to a path, a c-shell user would do something like "setenv PATH ${PATH}:/home/myfiles/bin". The ${PATH} is the old value of PATH and causes the new directory to be appended.
unsetenv <variable> (c-shells only)
Clears out an environment variable. For example, for a text-based login session, a user might to "unsetenv DISPLAY" so that certain commands (e.g. emacs) do not try to create a window.
<variable>=<value>;export<variable> (Bourne-shells)
Sets the value of an environment variable. Note there should be no spaces around the "=". Example: "PATH=${PATH}:/home/myfiles/bin ; export PATH"
<variable>=
To unset a variable. Example "DISPLAY="
Sometimes there are some variables that we always want to set. We can customize the environment automatically by placing shell commands in a file that is automatically consulted when the shell starts. For bash,  the commands in ".bash_profile" are performed on login, and those in ".bashrc" are performed whenever a new shell is started.. For c-shells, the commands in ".login" are performed when you login, and those in ".chrc" are performed each time you start a shell. Usually, you would modify the commands in .login. Note these configuration files start with ".", so they are hidden files (see section on files). 

Job Control

To execute a command, simply type the name of the command at the shell prompt. For example, to start the emacs text editor, type: emacs <enter>. When the command has finished executing, you will get back the shell prompt. Putting an "&" at the end of a command causes it to run in the background. That is, the shell prompt returns immediately so that more commands can be issued. The background command will run concurrently with any subsequent commands. In this fashion, it is possible to be running multiple "jobs" at the same time. Here are some commands for manipulating multiple jobs:
jobs
List the currently running jobs.
<ctrl>-z
Suspend the current foreground job.
bg
Restart a suspended job in the background.
fg
Restart a suspended job in the foreground.
kill %<number>
kill (terminate) the job with the given number (obtained from "jobs").
kill -9 %<number>
Terminate with extreme prejudice.

Files and Directories

Unix maintains a tree-structured directory system. When you log in, you are automatically placed in your "home" directory. You can make subdirectories to organize your files. In referring to directories, there are some special conventions:
'~' represents your home directory (can also use '$HOME')
'.' represents the current directory.
'..' represents the parent of the current directory.
Some file-handling commands:
ls
List files in directory.
ls -l
Directory listing in extended format.
ls -a
Directory Listing including hidden files (starting with ".").
mkdir filename
Create a new (sub)directory.
cd directory
Change directory.
cd ..
Change to parent directory.
more filename
display contents of file one page at a time.
cat filename
display contents of entire file.
rm filename
Delete the specified file.

Other Essential Commands

exit
Leave current command shell. At top-level, this logs you out.
yppasswd
Change your password on central password server.
man command
Display manual page entry describing the command.
man -k term
Display commands related to this term.
xterm (or konsole) &
Start up a graphical terminal (only used under X-windows).

This page is maintained by Dr. John Zelle. Send comments to: john.zelle@wartburg.edu