Sie sind auf Seite 1von 4

UNIX Handout

The UNIX OS is considered to be the most secured system software


in comparison to every other cotemporary OS. No unauthorized user
can loon to UNIX! only the authorized user can loon to and access
the resources. The user authorization is the responsibility of UNIX
system "dministrator# once he or she does it# users are iven their
uni$ue userid and password. %very user should remember his&her
userid ' password as he&she will be prompted for the same whenever
the loin is tried by him&her. (ollowin steps are to be followed for
loin on to UNIX
". telnet ))).))).))).))) where ))) are the diits used for I*
address of the UNIX server# e..# telnet +,-.+..-/0.+-. This I*
address will be iven to you by correspondin 1ab
instructor&Teacher.
2. 3hen prompted for username# type your userid and press return.
4. 3hen prompted for password# type your password and press
return.
"fter performin above steps# you are loed on to the system and a 5
prompt will appear and the system is ready to accept your commands.
1 Some Basic commands
4ommand format6
commandname 78options9 7aruments9
4ommands6
ls 78lt#8la9 list the files in the current directory
cd 7dirname9 chane directory
pwd present wor:in directory6 where you are in the directory hierarchy.
m:dir dirname create directory named dirname
more filename view the contents of filename a screenful at a time
cp source dest copy file named source to file named dest
2 Printing:
lpr 7 8* destination 9 7 8num copies 9 7 file;s< 9
3 Redirecting output from a program:
proram = outfile put the output of proram into new file outfile
e.. s+.pl = s+.out
proram == outfile append the output of proram onto e)istin file outfile
e.. s+.pl == s+.out
proram > infile ta:e the contents of infile as input to proram
e.. s-.pl > nicotiana.fa
4 More commands:
head filename view the first +0 lines of filename
tail filename view the last +0 lines of filename
file filename show what type of file filename is
mv source dest chane name of file from source to dest
rm > filename = remove file named filename
rmdir 78r9 filename remove directory named filename
ls ? rep te) ta:e the output of ls and loo: for @te)@ in it
Guide to the VI Editor
i is a full screen editor available on computers runnin the Uni) operatin system. This
handout is an introduction to file editin with i.
3hen you are usin i# it is important to :now which mode you are in6 the edit mode or the
input mode. 3hen you are in the edit mode# the :eys you type are editin commands that
perform operations on your file# such as movin the cursor# deletin characters or lines# etc.
3hen you are in input mode# all the characters you type will be inserted into your file.
3hen you first access i# you will be in edit mode. Once you enter input mode# all the
characters you type will be inserted into your file until you end input mode and return to edit
mode by pressin the Esc :ey.
Some useful 4ommands
i filename enter i
:!" leave i and save the chanes
:"# leave i without savin the chanes
u undo last chane
$ undo all chanes on current line
%ommands for Moing &round in the 'i(e
h left
) down
* up
( riht
Space Bar forward one character
+, bac:ward one character
- beinnin of ne)t line
. beinnin of previous line
+$ scrolls up
+/ scrolls down
B bac:ward one word
0 forward one word
e end of current word
! word after this word
, home screen line
M middle screen line
1 last screen line
G o to specified line
2 search forward for the strin
3 search bac:ward for the strin
%ommands for Ma*ing %hanges
ES% end the te)t to be inserted
i insert te)t before the cursor
a insert te)t after the cursor
o insert a new line after the current line
4 insert a new line before the current line
& append at end of current line
I insert at beinnin of current line
5 delete the character on which the cursor is set
dd delete a line
rz replace the current character with z
s replace one character with several characters
ns replace n characters with one or more characters
c! replace a word with te)t you type in
cc replace line with te)t you type in
% replace te)t from cursor to end of line
n66 copy n lines into buffer
p copy te)t from buffer into file
n! filename copy line n into file named filename
r filename copy file named filename into current file
4reatin source file ;4 proram files<
Type
vi filename.c
at 5 prompt# a blan: screen will appear where usin vi commands you can edit and save your
file.
4ompilin 4 prorams under Uni)
1etAs start by compilin the proram fi(ename7c.
Type6
cc fi(ename7c
Note6 The default 48compiler on most systems will probably be called cc. 2ut there may be
other compilers you can use. In particular# the popular BNU 48compiler can often be invo:ed
with the command gcc. On 1inu) systems# the BNU compiler is the default compiler#
so gcc does the same as cc.
If you list files in the current directory# you should find that this has produced a proram
called a7out. Cou can then run it by typin6
72a7out
where the D72D specifies a filename in the current directory.
letAs suppose that you want to ive your e)ecutable proram the name De5efi(eD# rather than
the default name Da7outD. Of course# you could Eust rename the file# but it is better to use the
D.oD option to tell cc what filename to create.
cc .o e5efi(e fi(ename7c
"nd of course# to run it you would type6
72 e5efi(e
Important: 8orma((9: a group of students are gien a sing(e userid ; pass!ord7 <his
resu(ts into a common home director9 for that particu(ar group7 If a(( students of that
group create and sae their source code fi(e =%2%-- fi(e> in this home director9 then
there ma9 ?e co((ision in the name of fi(es gien ?9 t!o different students7 <herefore:
!hen 9ou (ogin for the first time create 9our o!n director9 and change 9our current
director9 to the ne!(9 created one ?9 using appropriate commands of $8I@ as
discussed ear(ier7 <his act !i(( not on(9 aoid the naming co((ision ?ut a(so: a(( the fi(es
that 9ou create: gets stored in 9our o!n director9 and 9ou can get a ?ac*up of it on 9our
porta?(e storage deice for future references7

Das könnte Ihnen auch gefallen