File: unix.html
Updated September
24, 2008
Basic Unix Commands
Unix is an
operating system used in our work stations. Its advantages are:
Some of the current
versions of UNIX are:
User Interfaces
Users interact with UNIX in
two distinct ways:
FILES - DIRECTORIES -
SHELLS
Files
Files are the most basic
units of information that can be stored. Files may contain text, programs,
data, images, sounds, or other items.
Directories
If files are like the
documents in a filing cabinet, then directories are like drawers of a filing
cabinet ( or folders of Windows XP). Hierarchical
directories or trees may be constructed. A directory that is contained in
another directory is often called a subdirectory. The very top directory in the
hierarchy is called the root directory and it is denoted by the / character.
/home/jyk0/private/engr1
will be the name of my private
engineering 1 directory.
/home/jyk0/public/engr1
will be the name of my public engineering
1 directory.
Shells
The shell program accepts
commands from the user, interprets them and executes them thus providing an
interface with the computer. An early UNIX shell is the C shell ( or csh).Was popular for
interactive use. Lists of commands that will be executed by the shell are
called shell scripts. In recent years there are other modern shells such
as Korn shell (ksh) , Tenex C shell ( tcsh), Bourne shell ( bsh), etc.
Commands
Summary
Name |
Purpose |
Syntax |
Notes |
& |
places a process in the background |
command & |
|
cat (or more ) |
displays the contents of a file |
cat filename |
|
cc ( or gcc ) |
compiles C programs and creates an executable file ( default name a.out) |
cc FileName.c [options] |
-o name of executable and many other options |
c++ ( or g++) |
compiles C++ programs and creates an executable file ( default name a.out) |
c++ FileName.cpp [options] |
-o name of executable and many other options |
cd |
changes directory |
cd directory_name |
.. indicates parent directory |
clear |
clears the screen |
clear |
|
cp |
copies files |
cp source destination |
. indicates current directory |
emacs |
invokes the editor |
emacs [filename] |
emacs & will keep xterm active |
f77 |
compile FORTRAN 77 programs and creates an executable file ( default name a.out) |
f77 fileName.f [options] |
-o name of executable and many other options |
ifort |
compile FORTRAN 90 programs and creates an executable file ( default name a.out) |
ifort fileName.f 90 [options] |
First run the
command ( or include in profile) . /usr/local/bin/setup-intel-compilers (note the leading dot and space) |
Our LEAF specific: |
$g++ will compile C++ $F90 will compile f 90 |
But you must first run both statements on the right ( or include in profile) |
. /usr/local/vni/imsl/cnl600/linux/bin/cnlsetup.sh . /usr/local/vni/imsl/fnl600/lnxin100i32/bin/fnlsetup.sh (note the leading dot and space). |
exit |
logs a user out |
exit |
|
jobs |
list the running processes |
jobs |
|
kill |
stops a process |
kill [ option] process number |
-9 immediate kill |
ls |
displays the contents of current (or specified) directory |
ls [option] dirname |
-l long list -a all files |
man |
the unix help system |
man command |
try man g++ , man more , etc |
mkdir |
makes a new directory |
mkdir directory_name |
|
more ( or cat) |
displays the contents of a file one screen at a time |
more filename |
|
pwd |
prints present working directory |
pwd |
|
rm |
removes a file |
rm filename |
|
rmdir |
removes a directory |
rmdir directory_name |
|
|
|
|
|