|
CSCI A348/548
|
A Unix Command Summary
This is a short and simple summary of frequent commands that you need to know in order to use a Unix machine such as
www.burrow.cs.indiana.edu
where you will be working for A348/A548 this semester. We will refer to this machine both as
www.burrow.cs.indiana.edu as well
as burrowww.cs.indiana.edu since
both names are correct and refer to it.
Notice though the number of w's in the second name (is 3).
Unix Shells
A Unix shell is an interactive command interpreter that accepts the commands that you
type, and runs the appropriate program to process them. There are a number of popular shells
in unix systems, including the "C" shell variants (csh, tcsh), korn
shell variants (ksh, zsh) and bourne shell variants (sh,
bash). The first in each of the variants is the original shell, and the second one
is the recent improved version. Most shells have similar look and feel, but the newer ones
(tcsh, zsh, bash) have advanced features such as
command and file completion, command-line editing etc. You can change a shell by running
the "chsh" (change shell) command.
To change your shell that you use on burowww, you will need to log in
to paca, the NFS server for the Burrows. Once you log in, type the command
which <shell name>
(replace <shell name> with the shell you choose). This will tell you where the shell is located (e.g.,
csh is located in /usr/local/bin/csh). Next, type chsh, enter the new shell when
prompted, and you are done. Note that you will have to log out of paca, and log back in to one of the burrows machines
when you are done. It takes around 5 minutes or so for the shell changes to propagate to all the machines. The default
shell on the burrowww is csh which works just fine for me.
Every shell has its own settings file in which you can specify special configuration options. See the manual page for your shell to get the details of the syntax and format of this file.
The Unix File System
The Unix file system provides the permanent storage for all the data used by the operating system. This
includes all the data files (e.g. the data we'll serve from Apache) and all the program executable files
(e.g. Apache itself, httpd). As in essentially all operating systems you are going to use, the
Unix file system is organized as a tree-like structure of directories and files. More often than in other
mainstream operating systems, any part of the file system can physically reside on file servers, usually
interconnected by the NFS (Network File System) protocol. An important example for this class: your own home
directory on the IU Burrow cluster (e.g. /u/dgerman/) resides on the hard disks of the server
called paca.cs.indiana.edu.
Unix Paths
Most Unix commands are actually programs that run when you type in the command. Some commands are built-in to the shell that you use. When you type in a command, the shell looks for this command in a list of directories that you specify. This list of directories is the path. Depending on the shell you are using, the syntax for declaring the path will be different, but the usual set of directories to include in the path are (some of these paths are IU CSCI Burrows cluster specific):
.:/bin:/usr/bin:/usr/local/bin:/usr/ucb:/usr/etc:/sbin:/usr/sbin:/usr/ccs/bin:/usr/dt/bin:/usr/local/gnu/binKeep in mind that the longer the path is, the longer it takes the shell to search through all the commands in the path. You might want to look at these directories to see if there are commands in there that you do use. If not, you may want to remove the paths. Some shells create an index structure of all the commands when they start up, which reduces this searching time.
Also, having the "." in your path allows you to run your scripts and programs from the current direcory without having
to type "./" in front of the script or program name.
Commonly used Unix Commands
Here is a list of commonly used unix commands in alphabetical order. Each command includes a description and typical invocations. Note that almost all the unix commands accept command line arguments and options that usually start with a dash (-). The options can be stacked (i.e., if a command accepts options -a and -b, it will also accept -ab).
cat
chmod
chmod nnn filename This changes the
permissions of the file to the 3-digit octal number nnn,
the first digit corresponding to the user, second for the
group, third for everyone else. e.g., chmod 700
filename changes the permission of the file to
read, write, execute by you, and no access for anyone
else.
chmod [options] filename In this mode,
[options] is of the form x[+/-]y where x is zero or more of
u,g,o (user, group, other) and y is one of (r,w,x). e.g.,
you can turn on read and execute permission for a file for
the group and others using chmod go+rx filename.
cp
cp file1 file2. The -r option can be used to copy
recursively.
date
diff
du
find
find . -name "filename_with_wildcards" -print. See
the manpage for further options.
grep
grep "string" filenames.
gzip
gzip filename
gzip -d filename
kill
kill -[SIGNAL] pid_list where SIGNAL can be any
valid unix signal (e.g., HUP, TERM, STOP, CONT) and pid_list is
a list of process IDs (can be looked up by the ps command).
ls
lynx
mkdir
mkdir
directoryname
mv
ps
pwd
rm
rmdir
rm -r
tar
tar cvf newarchivefilename.tar <list
of files and directories>
tar xvf archivefilename.tar
top
which
which httpd will tell you which httpd you will
run if you just typed httpd at the prompt).
who
A348/A548