Академический Документы
Профессиональный Документы
Культура Документы
Typographical definitions
The following typographical conventions are used while typing unix commands:
1) Characters in bold face are commands to be typed as is!!.
2) Characters in italic face indicate arbitrary file or directory names.
3) Words inserted between square brackets [ ] indicate the keyboard keys to be pressed.
Example,
% ls any directory [Enter]
means "at the UNIX prompt %, type ls followed by the name of some directory, then press the key marked
Enter"
4) Don't forget to press the [Enter] key: a command you typed onto the computer screen will not be
executed without pressing this key.
Notice: UNIX is case sensitve, so LS is not the same as ls.
The same applies to filenames,
so sequence.txt, Sequence.txt and SEQUENCE.TXT are three different file
names. However, DOS and Windows do not make these distinctions.
NetWare series of network operating systems for the PC, followed by Microsoft with the development of
Windows NT.
The original PCs were not really suitable for running a multi-tasking operating system like Unix. As they
became more powerful, apart from gaining enough power to run Windows, some people began to think they
might be able to run some form of Unix. One of those was George Tannenbaum, who coded a small version
of Unix called minix for the PC. One person who was interested in minix was a computing student in
Finland called Linus Torvalds. Linus became frustrated with some of the limitations of minix (many of
which stemmed from it's design philosophy of supporting the lowest common denominator) and the
licensing, which made it difficult to fix the parts of minix which he thought were broken. Linus decided to
code his own operating system based on Unix. The first release was in 1991, when he invited anyone and
everyone via the Internet to have a look through his code and help to develop it.
As it turned out, Linus was very good at fostering a community around Linux. He is credited with being
very congenial, willing to let others take or share credit for their work and fairly liberal in deciding which
additions should go back into Linux itself. These features, along with the rise of the Internet as a means of
communicating and sharing data were instrumental in building Linux into a very popular and strong
operating system. Linux was placed under the GNU General Public Licence (GPL), which is a copyright,
but stipulates that the code should always be made available with the program (and those derived from it). In
this way, there is a legal guarantee that the code hiding (and consequent forking) which happened to
Unix cannot happen to Linux.
To the user, Linux is almost indistinguishable from other Unices. The rise in popularity of Linux has also
helped raise the level of knowledge of Unix amongst millions of students around the world over the last
decade. There are now a great number of people working in computing who have Unix knowledge and
skills. There are also other free Unices which have benefited from all of this. The most famous are the
variants of BSD (Berkeley Systems Distribution) for the PC which have a reputation for quality. As I write
this Unix, whether on a PC, a workstation or a big server, is increasing again in popularity. 60% of all web
servers on the Internet use Apache (a free web server) running on Linux or Unix, up from a little over 50% a
couple of years ago. Around 25% of servers now run Linux, up from almost nothing a few years ago.
Amongst Internet service providers usage is even higher (44%) - since Linux comes with source code it can
be modified to run on custom rack-mountable hardware which is perfect for serving large numbers of
connections. Amongst Universities usage of Linux is also strong - many Universities still have large
amounts of Unix expertise and Linux fits in well. Also, Linux is extremely inter-operable with most other
systems, speaking most network protocols and able to use many different file-systems, making it perfect in
an environment with many computing platforms.
The rise of Linux brings us pretty much up to date. At the time of writing of this history, it is unclear
whether this will lead to any significant change on Microsoft's hold over the desktop market. One thing is
clear - there are some interesting times ahead.
1. File system
In Unix, the files are organized into a tree structure with a root named by the character '/'. The first few
levels of the tree look like this:
Your own files form a subtree of this trees structure. For example, in many systems the user files are
subdirectories of a directory named `home' or 'people' within `usr'; if we had users Jack and model6, for
example,
Jack's home directory would be /usr/people/jack (on IRIX), and all his files would be within that
subtree, and the analogous statement would hold for model6.
Suppose model6's directory looks like this:
2. File Types
There are four types of files in the Unix file system.
2.1 Ordinary Files
An ordinary file may contain text, a program, or other data. It can be either an ASCII file, with
each of its bytes being in the numerical range 0 to 127, i.e. in the 7-bit range, or a binary file, whose bytes
can be of all possible values 0 to 255, in the 8-bit range.
will list the contents of your class directory, no matter where you currently are in the file system.
What do you think
% ls ~
would list?
What do you think
% ls ~/..
would list?
Summary
ls
ls -a
mkdir
make a directory
cd directory
cd
cd ~
cd ..
pwd
% cp ~/1A3Y.pdb .
(Note: Don't forget the dot "." at the end. Remember, in UNIX, the dot means the current directory.)
The above command means copy the file 1BVQ.pdb to the current directory, keeping the name the same.
Exercise
Create a backup of your 1A3Y.pdb file by copying it to a file called 1A3Y.pdb.bck
everything
in those directories. Use it very carefully, once it was deleted there is no way you can get them back easily.
Exercise
Create a directory called tempstuff using mkdir , then remove it using the rmdir command.
Summary
cp file1 file2
mv file1 file2
rm file
remove a file
rmdir directory
remove a directory
cat file
display a file
more file
head file
tail file
wc file
Text Editors
There are three basic editors you can use for editing the text file:
vi editor (screen editor, a default editor on all UNIX machines. A little bit hard to learn but you should
master it)
vi filename [Enter]
jot editor (only available on IRIX. A very simple and easy to use, GUI based editor. You should use it here)
jot filename [Enter]
nedit editor (Really good multi-function GUI based text editor. Programmers love it and is available on our
SGIs)
nedit filename [Enter]
2.1 Redirection
Most UNIX commands will write to the standard output (that is, they write on to screen), and many take
their input from the standard input (that is, they read it from the keyboard). The standard error by default,
will aso write to the screen.
We have seen one use of the cat command is to write the contents of a file onto the screen.
Exercise
Using the cat, create another file called amino2.seq containing the following residues: ASP D, CYS C, VAL
V, GLU E (Note each will contain a 3 letter and one letter codes as above)
You should now have two files: amino1.seqand amino2.seq. We will now use the cat command to
put amino2.seqinto amino1.seq. Type
% cat amino2.seq >> amino1.seq
What this is doing is reading the contents of amino2.seq and then appending the text to the file amino1.seq
To read the contents of amino1.seq, type
% more amino1.seq
2.4 Pipes
To see recent logins of users and terminals on your system computer type
% last
One method to get a sorted list of user names is to type,
% last > names.txt
% sort < names.txt
This is a bit slow and you have to remember to remove the temporary file called names.txt when you
finished. What if you really want to do is connect the output of the last command directly to the input of the
sort command. This is exactly what pipes do. The symbol for a pipe is |
For example, typing
% last | sort
will give the same result as above, but quicker and cleaner.
To find out how many users are logged on, type
% who | wc -l
Summary
command1 | command2
sort
sort data
last
2.5 Wildcards
The character * is called a wildcard, and will match against none or more character(s) in a file (or directory)
name. For example, in your pdb directory, type
% ls *.aln
This will list all files in the current directory ending with ".aln"
The character ? will match exactly one character.
So ls ?ouse will match files like house and mouse, but not grouse.
Try typing
% ls ?
use that option, you are advised to rename the compiled file immediately, otherwise the next such file will
overwrite it and it will be lost.
Summary
man command
whatis command
apropos keyword
This will compress the file and place it in a file called science.txt.Z
To see the change in size, type ls -l again.
To uncomress the file, use the uncompress command.
% uncompress science.txt.Z
gzip
This also compresses a file, and is more efficient than compress. For example, to zip blast.txt, type
% gzip blast.txt
This will zip the file and place it in a file called science.txt.gz
To unzip the file, use the gunzip command.
% gunzip blast.txt.gz
file
file classifies the named files according to the type of data they contain, for example ascii (text), pictures,
compressed data, etc.. To report on all files in your home directory, type
% file *
history
The C shell keeps an ordered list of all the commands that you have entered. Each command is given a
number according to the order it was entered.
% history (show command history list)
If you are using the C shell, you can use the exclamation character (!) to recall commands easily.
% !! (recall last command)
% !-3 (recall third most recent command)
% !5 (recall 5th command in list)
% !grep (recall last command starting with grep)
You can increase the size of the history buffer by typing
% set history=100
Shell Scripting:
Each file (and directory) has associated access rights, which may be found by typing ls -l SEQ1.
-rw-r--r--
1 model6 user
r (or -), indicates read permission (or otherwise), that is, the presence or absence of
permission to read and copy the file
w (or -), indicates write permission (or otherwise), that is, the permission (or
otherwise) to change a file
x (or -), indicates execution permission (or otherwise), that is, the permission to
execute a file, where appropriate
w means that users may delete files from the directory or move files into it;
x means the right to access files in the directory. This implies that you may read files
in the directory provided you have read permission on the individual files.
So, in order to read a file, you must have execute permission on the directory containing that file, and hence
on any directory containing that directory as a sub directory, and so on, up the tree.
Some examples
-rwxrwxrwx a file that everyone can read, write and execute (and delete).
-rw------- a file that only the owner can read and write - no one else
can read or write and no one has execution rights (e.g. your
mailbox file).
Symbol
Meaning
user
group
other
all
read
add permission
For example, to remove read write and execute permissions on the file SEQ1 for the group and others, type
% chmod go-rwx SEQ1
This will leave the other permissions unaffected.
To give read and write permissions on the file SEQ1 to the world,
% chmod a+rw SEQ1
% bg
Note: do not background programs that require user interaction.
3.4 Listing suspended and background processes
When a process is running, back grounded or suspended, it will be entered onto a list along with a job
number. To examine this list, type
% jobs
An example of a job list could be
[1] Suspended sleep 500
[2] Running netscape
[3] Running nedit
To restart (foreground) a suspended processes, type
% fg %jobnumber
For example, to restart sleep 100, type
% fg %1
Typing fg with no job number foregrounds the last suspended process.
3.5 Killing a process
kill (terminate or signal a process)
It is sometimes necessary to kill a process (for example, when an executing program is in an infinite loop)
To kill a job running in the foreground, type ^C (control c). For example, run sleep 500 then kill it with ^C
To kill a suspended or background process, type
% kill %jobnumber
For example, run sleep 500 & then type jobs to see its job number. If it is job number 1, type
% kill %1
To check whether this has worked, examine the job list again to see if the process has been removed.
ps (process status)
Alternatively, processes can be killed by finding their process numbers (PIDs) and using kill PID_number.
Run sleep 100 & again, then type
% ps
PID TT S TIME COMMAND
20077 pts/5 S 0:05 sleep 500
21563 pts/5 T 0:00 netscape
21873 pts/5 S 0:25 nedit
To kill off the process sleep 100, type
% kill 20077
and then type ps again to see if it has been removed from the list.
If a process refuses to be killed, uses the -9 option, i.e. type
% kill -9 20077
Note: It is not possible to kill off other users processes !!!
Summary
ls -lag
command &
^C
^Z
bg
jobs
fg %1
kill %1
ps
kill 26152
your old password, to prevent someone else from sneaking up, and changing your
password. Then it will ask for your new password. You will be asked to confirm your new password, to
make sure
that you didn't mistype. It is very important that you choose a good password, so that someone else cannot
guess it.
Here are some rules for selecting a good password:
Do not use any part of your name, your spouse's name, your child's name, your pet's name, or
anybody's name.
Do not use an easily-guessable number, like your phone number, your social security number,
your address, license plate number, etc.
Do not use any word that can be found in an English or foreign-language dictionary.
Do not use all the same letter, or a simple sequence of keys on the keyboard, like qwerty.
Do use a mix of upper-case and lower-case letters, numbers, and control characters.
Excercise
Change your passord after you login the first by typing
passwd [Enter]
Logging Out
It all depends on the OS you are running. Most Uinces have a nice GUI to let you click a button to
logout. Otherwise
just use exit command
At the login: prompt type in your user name and hit [Enter] key. Then it will ask for the passwod
and type a
password and hit the [Enter] key again. If the password given matches the password stored in the
computer
you will see something like:
IRIX Release 6.5 IP30 vishnu
Copyright 1987-2002 Silicon Graphics, Inc. All Rights Reserved.
Last login: Wed Sep 04 11:13:57 CDT 2002 by yuan@planck.utmb.edu
on your screen.
ftp
The ftp program lets you contact a remote server computers to initiate remote file transfers.
All computers do not implement the server function. Typically, UNIX systems have both the client
programs
and the server function (although the server may be turned off or restricted by the system manager
for
security reasons), allowing two-way connections between UNIX computers, initiated at either
end. Desktop
computers such as Windows PCs and Macintoshes typically only have the client programs, and
can initiate
connections to UNIX servers, but not to other desktop computers.
Example
#!/bin/sh
#
#***************************************************************************
************
# This bourne shell script will read in a PDB structure file then extract the
sequence
# and write the sequence out as one and three letter code and save them
into two files.
# It can also break up the boundle file into individual structure file if the PDB
file
# contains more than one boundle structure (NMR boundle).
#***************************************************************************
************
clear
echo "***********************************************"
echo "* Welcome to use pdbscan v1.0
*"
echo "* Written by Yuan Xu Jan. 8, 2002
*"
echo "* Please email any suggestions and comments to *"
echo "* yuxu@utmb.edu
*"
echo "***********************************************"
#
var=null
chk=""
seq=.seq
one=_1ltr
three=_3ltr
junk=null
echo " Please enter a PDB file name and hit Enter if done > \c"
read pdb
if test $pdb != "$chk"
then
echo "loading pdb file: $pdb"
fi
if [ -s $pdb ]
then
grep "SEQRES" $pdb | cut -c 12 > junk
var=`head -1 junk`
else
echo "Sorry, Could not find file: $pdb, try again!"
exit
fi
#
echo " Please enter a root file name for your output sequence files > \c"
read input
#echo "The root name you entered: $input"
echo "The root name you entered: $input"
seq1=$input$one".seq"
seq3=$input$three".seq"
echo "Your one letter and three letter code sequence files are:"
echo "$seq1 and $seq3"
# in case old files exist
if [ -s $seq1 ]
then
/bin/rm -rf $seq1
fi
if [ -s $seq3 ]
then
/bin/rm -rf $seq3
fi
# creat two output files
touch "$seq1"
touch "$seq3"
#
# get now the sequence:
# Now cut the field 5 of lines with SEQRES. Notice Space is also considered
as a field,
# then save field 5 and get the containt of field 5 and make sure it is A, B or
anything
#else
#
if test "$var" = "A" || $var = "B"
then
echo "The sequence starts from field 9"
grep "SEQRES" $pdb | cut -c20-70 > $seq3
echo "DONE!"
else
echo " The sequence starts from field 7"
grep "SEQRES" $pdb | cut -c20-70 > $seq3
echo "DONE!"
fi
#
# Now translate three letter code to one letter code:
num_res=`wc $seq3 | cut -c26-30` #count number of lines
echo "Total number of Residues: $num_res"
#then use sed to generate one letter code
A=ALA
C=CYS
D=ASP
E=GLU
F=PHE
G=GLY
H=HIS
I=ILE
K=LYS
L=LEU
M=MET
N=ASN
P=PRO
Q=GLN
R=ARG
S=SER
T=THR
V=VAL
W=TRP
Y=TYR
#
sed 's/ALA/A/g
s/CYS/C/g
s/GLU/E/g
s/PHE/F/g
s/GLY/G/g
s/HIS/H/g
s/ILE/I/g
s/LEU/L/g
s/LYS/K/g
s/MET/M/g
s/ASN/N/g
s/PRO/P/g
s/GLN/Q/g
s/ARG/R/g
s/SER/S/g
s/THR/T/g
s/TRP/W/g
s/ASP/D/g
s/TYR/Y/g
s/VAL/V/g' $seq3 > $seq1
#
# To remove the space between the two residues
sed 's/ //g' $seq1