You are on page 1of 27

BASICS OF UNIX STARTING TO USE UNIX All UNIX systems are administered and maintained by a SYSTEM MANAGER or a SYSTEM

ADMINISTRATOR(SA). USER ACCOUNT  Every user is given a password- a secret code he must type in every time he uses the system  A unique identity which identifies him to the system - called USERID  Once a user is given a userid and a password in the system, he has an ACCOUNT on that system
FOILS ON THE UNIX OS & SHELL PROG. 14/ 399 BASICS OF UNIX - 1

User Account contd...

 Account keeps track of most activities performed by the user  An Account has certain predefined limits also, like how much disk storage space is allowed for files USERID

 Normally chosen by System Administrator
 Used by UNIX to identify user  For example, any data files created by user A will be “owned” by his UserID  NOT secret

FOILS ON THE UNIX OS & SHELL PROG. 15/ 399

BASICS OF UNIX - 2

he goes offline FOILS ON THE UNIX OS & SHELL PROG.3 .THE PASSWORD  IS secret  Encrypted by the system. 16/ 399 BASICS OF UNIX . nobody can read it  If forgotten. only SA can give out a fresh password LOGGING IN AND OUT  Terminal needs correct connections to computer running UNIX  User is online when connected  When connection is lost.

 Terminal may be local which is directly cabled (hardwired) to the computer remotely connected via modems and telephone lines - LOGGING IN  The process user goes through to start his work is called logging In  Consists of typing UserID and the password  When the UNIX terminal is ready to use.4 .. it displays : FOILS ON THE UNIX OS & SHELL PROG.Logging In And Out cond. 17/ 399 BASICS OF UNIX ..

5  FOILS ON THE UNIX OS & SHELL PROG. and presses Return login : Amit   Backspace or Delete key allowed in some systems to correct errors On others. 18/ 399 .Logging In contd.. press the Return key anyway and wait for message which informs login was incorrect. and try again BASICS OF UNIX . login : _  User types in his UserID..

6 . 19/ 399 BASICS OF UNIX ..Logging In contd.  Once the UserID has been entered.. UNIX does not echo it on screen This helps in security and the feature is known as echo suppression   FOILS ON THE UNIX OS & SHELL PROG. UNIX prompts for password: Password : _  Type password and press Return As password is typed.

20/ 399 .THE SHELL PROMPT  After successful login.7 FOILS ON THE UNIX OS & SHELL PROG. author Stephen Bourne) $ % (bsd UNIX support) # (System Administrator) BASICS OF UNIX . a prompt is displayed  User gives series of commands to do his work  Shell reads and interprets commands  Each shell displays a different prompt: Bourne Shell Korn Shell C Shell Superuser $ (default.

8 .LOGGING OUT  User can terminate session by pressing Ctrl + D  Sends end-of-file signal to UNIX  Tells the shell no more data coming  Shell terminates  UNIX logs the user out  Screen returns to the login prompt login : _ FOILS ON THE UNIX OS & SHELL PROG. 21/ 399 BASICS OF UNIX .

9 . by default. 22/ 399 BASICS OF UNIX .NOTES …  Each command in UNIX needs to be terminated by a Return key-press to execute it  UNIX DOES distinguish between upper and lower case letters  If a UserID is given as amit. uses lowercase FOILS ON THE UNIX OS & SHELL PROG. typing Amit at the login prompt will result in an incorrect login attempt  UNIX.

very rare  A command is brief set of letters. followed by options or arguments  General command format: command options expression filename Arguments  Options modify behavior of command  Marked with leading hyphen Example: $ ls -a FOILS ON THE UNIX OS & SHELL PROG. common to very. 23/ 399 BASICS OF UNIX .10 .SHELL COMMANDS  UNIX can be simple to complex.

.  Expression is group of characters used as input to command  Filename is name of file which command refers to in some way  All arguments are not mandatory in every command Checking Date  System date in UNIX checked through the date command  UNIX uses 24 hour clock and gives the time upto the second FOILS ON THE UNIX OS & SHELL PROG..Shell Commands contd.11 . 24/ 399 BASICS OF UNIX .

Checking Date contd. $ date Thu Jan 08 14:07:43 IST 1998 $_ Output Who Is There?  The Who command displays: .Terminals they are logged into .12 .A list of all active users in system . 25/ 399 BASICS OF UNIX .Date and time they last logged on FOILS ON THE UNIX OS & SHELL PROG...

$ who stheer anasua indira amit User Names Terminal Date of login Month of login tty01 tty02 tty04 tty09 Jan Jan Jan Jan 08 08 08 08 14:01 14:50 15:06 15:10 Time of login  Argument can be added to the who command  am i ..The Who Command contd..If user shares his terminal with other users.13 . 26/ 399 BASICS OF UNIX . who am i used to check who has abandoned the terminal $ who am i stheer tty01 Jan 08 14:01 FOILS ON THE UNIX OS & SHELL PROG. and previous user has not logged out.

MULTIPLE COMMANDS  UNIX allows two or more commands to be entered on the same line  Put a semi-colon between each command.14 . then press Enter after the final command $ date. who Thu Jan 08 15:12:43 IST 1998 stheer anasua indira amit $_ tty01 tty02 tty04 tty09 Jan Jan Jan Jan 08 08 08 08 14:01 14:50 15:06 15:10 FOILS ON THE UNIX OS & SHELL PROG. 27/ 399 BASICS OF UNIX .

It then returns to the shell prompt $ what is the date what is the date: not found $ who aam I who aam I : not found FOILS ON THE UNIX OS & SHELL PROG.UNIX gives a message saying the command is not found . 28/ 399 BASICS OF UNIX .Non Existent Command !!  When non-existent command is entered .15 .

Display On The Screen  echo command displays a string on the screen $ echo this is fun!! this is fun!! $_ FOILS ON THE UNIX OS & SHELL PROG.16 . 29/ 399 BASICS OF UNIX .

17 .Changing The Password  When a user’s UNIX account is set up. 30/ 399 BASICS OF UNIX . the SA assigns a UserID and a password  Password can be later changed by user by passwd command  UNIX asks for old password first (why?)  Then passwd prompts for new password FOILS ON THE UNIX OS & SHELL PROG.

like the length of the password should be a minimum of 8 characters  If new password does not meet required criteria. 31/ 399 BASICS OF UNIX .18 . either old or new. is displayed on the screen as they are typed  The passwords are stored in a file called the “/etc/password” file FOILS ON THE UNIX OS & SHELL PROG. passwd asks you to reenter the new password to ensure match with first password  No password.SETTING PASSWORDS  Some systems need all passwords to meet certain specifications. you are so informed and asked to enter a new choice  Finally.

.Setting Passwords contd. 32/ 399 BASICS OF UNIX ..  SCO UNIX and some other UNIX systems offer automatic generation of pronounceable but obscure passwords like klibrufar !!  SA can delete relevant entry from password file to allow user to enter his login if he forgets his password $ passwd Changing password for stheer Old password : mineonly New password : annieta1 R-enter new password : annieta1 $_ Not Echoed On Screen FOILS ON THE UNIX OS & SHELL PROG.19 .

 They are placed in a file called the global login profile  Shell executes commands in this file whenever a user logs in  User can modify some or all of these defaults either temporarily or permanently for all sessions  He runs commands of his choose to modify his environment during a given session  These changes last till he logs out FOILS ON THE UNIX OS & SHELL PROG.20 . or default settings that affect all users.LOGIN PROFILES  SA provides global actions. 33/ 399 BASICS OF UNIX .

34/ 399 BASICS OF UNIX . followed by personalized profiles for each user gives a lot of flexibility  Similar to AUTOEXEC. he can place these modifications in his home directory (covered in the next session) in his personal login profile  This gives the user a permanent startup environment each time he logs in  Having a global profile for everyone...Login Profiles contd.  Or.21 . it is run automatically when user logs in  Bourne shell looks for a file called profile under directory etc  If found.BAT files in DOS. all commands in it are executed FOILS ON THE UNIX OS & SHELL PROG.

profile (the user’s personal login profile) in the user’s home directory  If found. it executes it  Then shell prompt appears on screen Global Login Profile executed when user1 logs in User Login Profile For User 1 executed every time user1/2/3 logs on User Login Profile For User 2 User 3 .Login Profiles contd.22 .has User 1 User 2 NO user login profile executed when user2 logs in FOILS ON THE UNIX OS & SHELL PROG.  Next.. 35/ 399 BASICS OF UNIX . it looks for a file called ..

PATH or doc)  Variable names with capital letters are usually reserved for standard variables with pre-determined UNIX meanings  Contents of all shell variables can be seen with the set command FOILS ON THE UNIX OS & SHELL PROG. 36/ 399 BASICS OF UNIX .23 .SHELL VARIABLES  Shell variables are like variables used in conventional programming languages  Shell variables allow user to provide a name or variable identifier for some entity (example.

24 . normally ansi or vt100 FOILS ON THE UNIX OS & SHELL PROG. 37/ 399 BASICS OF UNIX . $ set HOME = /usr/stheer IFS= MAIL=/usr/mail/stheer PATH=:/bin:/usr/bin PS1=$ PS2=> TERM=ansi $ bin : binary object files TERM :terminal type..Shell Variables contd..

THE PRIMARY PROMPT  PS1 stores the primary prompt symbol ($. prefixed with a $ displays content of variable rather than the variable name itself FOILS ON THE UNIX OS & SHELL PROG. by default)  Setting PS1 to any character string will change the primary prompt $ PS1=„Enter your command :‟ Enter your command : _ The prompt changes to Enter your command :  No spaces are allowed before or after the assignment operator “=”  The single forward quotes when setting PS1 ensures that spaces within the new prompt string are transferred to PS1  Any variable name. 38/ 399 BASICS OF UNIX .25 .

. 39/ 399 BASICS OF UNIX .The Primary Prompt contd. Enter your command: echo PS1 PS1 Enter your command : echo $PS1 Enter your command : Content Of Primary Prompt PS1 is displayed THE SECONDARY PROMPT (PS2)  Used when UNIX thinks you have started a new line without finishing a command  New lines can also be included in a quoted string  After pressing Enter at end of first line..26 . shell displays it’s secondary prompt and waits for more input FOILS ON THE UNIX OS & SHELL PROG.

shell understands command is complete. now changed to More Input :. Countrymen  > lend me your ears !!”  Friends. Countrymen  More Input : lend me your ears !!”  The secondary prompt. waiting for the final quotes Changing the secondary prompt to More Input :.27 FOILS ON THE UNIX OS & SHELL PROG.The Secondary Prompt cond.. > by default. Countrymen lend me your ears !! $ echo $PS2 > $ PS2=“More Input : ” $ echo $PS2 More Input : $ echo “Friends. 40/ 399 . The secondary prompt.  After final quote and newline. waiting for the final quotes BASICS OF UNIX . Romans. and executes it  By default. PS2 stores the character > Example: Enter your command : PS1=„$‟ $ echo “Friends.. Romans. Romans.

 $$ &  .

9034914:3/  4.9890/.2 34914:3/  $ %& $ $!#  .0 8.422.3 90 . 2088..422.08 .3/ 8 039070/ & .43 89039 422.9890/..90  .3/  O 03 343 089039 .2   4.3/ 8 349 14:3/ 9 903 709:738 94 90 80 574259   .

 $$ &  .

4.49881:3 9881:3 *  $ %& $ $!#  .85.3//85.7003  0.7003 O 0.422.897343 908. 3%0$.8.

 $$ &  .

88/ 5742598 147 30 5..33 %0 !.3 -0 .8838 .3/ .3/ O & ..88 147 4/ 5.8847/ 1789  O %03 5. 5.8847/  $ %& $ $!#   .4:39 8 809 :5 90 $ ..8847/ O 03 .422.. :807 8 & .30/ - :807 - 5. &807 .8847/ O !.907 ..88/ .8847/ .

 $$ &  .

0/ 43 90 8. 9 1789 5.8847/ 84:/ -0 .70 950/ O %0 5. 30 ..7003 .9..70 89470/ 3 .4.88 4: 94 7003907 90 30 5.8847/ 0907 4/ 47 30 8 /85. 5.88/ .0/ 90 ..0 O 3.7.9078 O 1 30 5. 5.8847/ O 4 5. 232:2 41  .079. 10 .9438 0 90 039 41 90 5.$%% !$$ #$ O $420 889028 300/ .. 4: .80/ 94 03907 .7907.1.3/ .3 850.8 90 .8847/8 94 2009 .70 84 314720/ .8847/ /408 349 2009 706:70/ .8847/ 94 038:70 2.8847/8 .

09.

5.8847/ 10  $ %& $ $!#  .

 $$ &  .

439/ O $ & . * 49 .7003  $ %& $ $!#  .8847/ 10 94 .335.-0 -:9 4-8.943 41 57434:3.4 :807 94 03907 8 43 1 0 147098 8 5.8847/8 . # 03907305.3/ 8420 4907 & 889028 41107 .3 /0090 700.:70 5.8847/8 0 -7:1.40/ 3 $.8847/14789007 /5. 0307.39 0397 1742 5..3309.7  O $ .88/ ..8847/.:942.8847/ 5.3309.8847/.8847/23043 05.$0993 !.9.0.

 $$ &  .

03 808843 O %080 .07 . :8078 O %0 .110.89 9 0 48 4:9  $ %& $ $!#  .422. . 10 .422. 8088438 O 0 7:38 .0/ 3 .:9 809938 9. 43 57410 O $0 00.9 .9 ..:98 0907 902547./08 4-.7 47 5072.3 24/1 8420 47 ..308 .7432039 /:73 . 41 9080 /01.3039 147 . :807 48 3 O &807 .3/8 41 8 . ..4480 94 24/1 8 03.70 5.0/ 90 4-..  !# $ O $ 574.3/8 3 98 10 030..9438 47 /01.:908 .

 $$ &  .

 :807 .422.70 00.9438 3 8 420 /70..4...43 !74108 . 4-. .947 .3039 89. 5072.:942. 49 41 10-9 O $2.7 94 &%  % 108 3  $ 9 8 7:3 ..3/8 3 9 .. O 1 14:3/ .0/ 57410 :3/07 /70..08 90 :807 ..79:5 03.9.3 .08 .7432039 0. 43 57410 O %8 . 10 ..:90/  $ %& $ $!#  .0/ 574108 147 0.070/ 3 90 309 808843 3 8 507843.0 9080 24/1.07430 1440/ - 507843.439/ O 7 0 .947 09.3 5. 57410 147 0. 03 :807 48 3 O 4:730 80 448 147 . 920 0 48 3 O .

 $$ &  .

:90/0.947 O 114:3/ 900.7003 4-.550.43!7410 00. 10 .:90/ 03:807 483 &80743 !741047&807 00.0/ 57410 90 :807 8 507843..43 !74108 .439/ O 09 9 448 147 . 43 57410 3 90 :807 8 420 /70.07920 :807.:9089 O %03 80 574259 .78 43 8.

.

:90/ 03:807 483 &807  :807 4357410  $ %& $ $!#  .4843 &80743 !741047&807 &807 .8 &807 00.

 $$ &  .

.7.-08:80/3 .2089.7.08 O $0.223..3-0 8003990809.099078.250 !%47/4.03943.70807..7/.-0/0391071478420 0399 0./0..$'#$ O $0.-08.70 :8:.7.4:80794574.0/14789.700.338 O 439039841.7.7..43.3/  $ %& $ $!#  .59.3:.-08 9570 /0907230/&20.422...7.-08.5747.-03.3/.7. 3.2047.-08. O '.80..

 $$ &  .

-08.$0'.439/ 8 09     .7.

: 8 7.

8 90 0 7  $     .

: 8 7.

2 . .

8 9 00 7 !  %  .

3 ..

: 8 7.

 950 3472..3847. 38   -3-3.3 ! $   ! $   %  #  .9108 %# 90723.74-0.9  $ %& $ $!#  ..

 $$ &  .

422.20 57010/9.3/* %0574259 .757425982-4  -/01.%!##!# !% O !$89470890572.7..089390 305742598973..9079...3/ O 485.3/ 39074:7.1907 90.7.3810770/94!$ O 3.209801  $ %& $ $!#  .. /85.8...-03.40/-0147047.08.7..88320394507.9078973 ..3 90.-07.422.7/6:49080380993 !$038:7089.30894 39074:7.43903941.70.3.:9 O $0993!$94.-03.422.7097.985.3090572.947  O %0830147.7.7574259 !$ 39074:7.

 $$ &  .

:/0/ 3 .7!74259.8 9 8 80.98 147 2470 35:9  $ %& $ $!#  .9 03/ 41 1789 30 80 /85.439/ 39074:7. 6:490/ 8973 O 1907 570883 3907 .422.0/ % $ # !# !% !$ O &80/ 03 & 938 4: .3/0.3/ 439039 1!72.422.84 -0 3..4!$ !$ 39074:7. .790/ .3/ 0.3/ O 0 308 .422.0 89.4!$ 39074:7.43/.422.3/ .. 30 30 94:9 1383 .3 .7!74259 !$8/85.%0!72.7 574259 .

 $$ &  .

30/94 4 70 35: 9  .38 4:3972 03 Q 03/2 04:70.907 .43/.6:4908 $$ &   $ %& $ $!#   ..4!$  ! $  47035:9 0.3/8.38  4:3972 03 03/2 04:70.6:4908  .7.78 Q %080.43/.:9  .9314790 13.43/ O 190713.43/.7 5742 5994 4 7035:9 %080.339080.3/8.38 4:3972 03 Q  47035:903/2 04:70.6:490.3/!$  0.7!74259.42 2 .43/..4  703/8 # 42 .4!$  47035:9 0.425090  .4  703/8 # 42 .78 0.250 39074:7.75742 59 34 .422.75742 59  -/01.:9089 O /01..3/3030 80 :3/0789.78  Q 703/8 # 42 .:9 !$89470890.%0$0.9314790 13.3/00.

 .