Docstoc

MULTI USER OPERATIONS

Document Sample
MULTI USER OPERATIONS Powered By Docstoc
					                     HISTORY OF UNIX
Unix is the most popular operating on multi-user systems. This OS started – off as a single
user system on a cast – off DEC PDP-7 machine at Bell laboratories in 1969. Ken
Thompson, with ideas and help from Dennis Ritchie and others, wrote a small general –
purpose OS which included utilities to manage files and processes on PDP-7, among other
utilities. The system developed attracted a large number of enthusiastic users and was
eventually transferred to a larger machine, the PDP-11/20.
                              In 1973, Thompson and Ritchie rewrote the UNIX OS in C,
breaking away from the tradition of writing Operating systems in assembly language.
                 Around 1974, UNIX was licensed to universities for educational purposes
and a few year later, was made commercially available MS-DOS was created much later
than UNIX, by which time the industry had begun to accept UNIX as the standard So the
design of MS-DOS has therefore been influenced by UNIX features.


Versions of Unix

The flexibility of UNIX. Which allows it to shaped to meet a variety of needs, has always
been one of its major attractions. Some of the popular versions of UNIX are:-
         Version                    Developed By

          UNIX SYSTEM             AT&T

          UNIX BSD (4.xx)         Berkeley Software Distribution of Berkeley University

          XENIX                   Microsoft for micros

          ULTRIX                  DEC for minis

          AIX                     IBM

FEATURES AND BENEFITS OF UNIX

The UNIX OS is available on machines with a wide range of computing power ranging from
microcomputers to mainframes, and on different manufacturer’s systems. This is due to the
following reasons:-




                                                                                       2

  B.I.M.T.A.S
    PORTABILITY
The system is written in a high – level language making it easier to read, understand change
and therefore, move to other machines. The code can be changed and compiled on a new
machine.

   MACHINE INDEPENDENCE
The system hides the machine architecture from the user, making it easier to write
application that can run on micros, minis and mainframes.

   MULTI USER OPERATIONS
UNIX is a multi – user system designed to support a group of users simultaneously. The
system allows for the sharing of processing power and peripheral resources, while at the
same time excellent security features.

    HIERARCHICAL FILE SYSTEM
UNIX uses a hierarchical file structure to store information. This structure has the
maximum flexibility grouping information in a way that reflects its natural states. It
allows for easy maintenance and efficient implementation.
UNIX SHELL
UNIX has a simple user interface called “THE SHELL” that has the power to provide
the hardware details.
PIPES AND FITERS
UNIX has facilities called pipes and filters which permits the user to create the complex
program from singular programs.
BACKGROUND PROCESSING
UNIX has a facility by which the user can start a task and then proceed to work on other
tasks while the system runs the first task in the background and the second in the
foreground. Background processing helps the user in effective utilization of time.

WHAT MAKES UNIX UNIQUE?
    It is the only OS written in high – level language.
    It was the first OS to introduce the hierarchical file system.
    The Kernel which is the basic OS program is the bare skeleton of the OS.


                                                                                        3

  B.I.M.T.A.S
         It uses a consistent format for files, making application programs easier to
          write. This format is called the ‘Byte Stream’ UNIX treats any file as a stream
          of byte which the user may manipulate in any way he pleases.
         The Kernel doesn’t incorporate a command interpreter – it uses a utility
          program to provide the user interface called “The Shell”

STARTING A UNIX SESSION – LOGGING IN
The user of UNIX – based system works at a user terminal. After the boot procedure is
completed i.e. the OS is loaded into the memory, the following message appears at each
user’s terminal:
LOGIN:
Each user has an identification called “user name”, or the ‘login name’ which he has to
enter when the login: message appears.
UNIX keeps track of all users’ names and other identification in a special file. If the
login name entered doesn’t match any of these user names, it displays the login;
message again. This ensures that only authorized people use the system.
                             When a valid user name is entered at the terminal the “$”
symbol is displayed on the screen. This is the UNIX prompt. When the user logs in he is
taken directly into his home directory.

ENDING A USER SESSION – LOGGING OUT
Once a user has logged into the system, the users work session continues until the user
instructs the shell to terminate the system. This is done by pressing <Ctrl> <d> at the
“$” prompt. To maintain security of files the user should never leave the terminal
without logging out.


SECURITY FOR THE UNIX USER – PASSWORDS
The procedure followed by user to start a UNIX session the login procedure – has been
explained earlier. The login procedure ensures, that only authorized users can try to
access the system.
However, it is easy for anyone to find out a user’s login name since this is displayed on
screen when being entered. Thus the login procedure is not a fool proof system.


                                                                                            4

  B.I.M.T.A.S
To overcome this problem, UNIX is allows an additional measure of security by
allowing the userto have a password associated with his/her name.
To login using password protected user names, the user has to enter not only the user
name but also the password.


CREATING PASSWORD
A user can add a password for his login name by the “password command” shown
below is the password command executed by the user:
                $passwd <RET>
                changing password for ‘anyname’
                new password
                $
The user is asked to re-enter the new password for confirmation. If this entry differs
from the earlier entry, then the password is not accepted by UNIX.


RULES FOR PASSWORD
    A user password in UNIX
    Cannot be less than 6-14 characters long.
    Can contain any character in the keyboard seat.
    Must contain at least 2 alphabetic characters and at least 1 numeric or special
      character.




CHANGING THE PASSWORD
A user can also change his password the “password command “. The steps followed by
the user to change his password are depicted below
               $passwd <RET>
               changing password for ‘anyone’
               old password
               new password
               re-enter new password

                                                                                         5

  B.I.M.T.A.S
               $
The “passwd” command asks for the old password to ensure that the authorized user is
trying to change the password.
Incase UNIX does not recognize the old password, it displays the message, SORRY
and the $ prompt appears on the screen.
               $ passwd <RET>
               changing password for ‘anyname’
               sorry
               $
If the old password is entered correctly then the user is asked to enter the new
password and re-enter it confirms. If the two entries do not match, then the user is
given another chance to enter the new password.
When changing the password, the new password should differ the old password by at
least 3 positions. That is, at least 3 characters much either be different, or must change
position.

UNIX COMMANDS
UNIX commands can be entered the “$” prompt appears on the VDU all UNIX
commands should be entered in lower-case. UNIX commands can be classified into
simple directory commands and file commands.

I.      DIRECTORY COMMANDS
Each directory is referred to using its path – name beginning from the root directory.

   Identifying the current working directory.
Command:          pwd (print working directory)
Function:         displays the full path – name for the current working directory

    Moving to different directory
Command:          cd (change directory)
Syntax:           $cd directory name
Function:         changes the working directory
The “cd” command without any path – name always takes the user back to the user’s
HOME directory.

                                                                                             6

 B.I.M.T.A.S
    Making new directories
Command:        mkdir (make directory)
Syntax:         $mkdir directory name
Function:       creates sub directories

    Removing a directory
Command:             rmdir (remove directory)
Syntax:              $rmdir directory name
Function:            removes empty directory
User can also delete the multiple directories
The full path – name may also be specified with “rmdir”

    Listing the contents of directories
Command:            ls (list the contents of a directory)
Syntax:             $ls directory name
Function:           Lists names of files and sub –directories of a directory
The directory name is optional if the names of the files and directories under the
current working directory are to be listed out.

II.     FILE COMMANDS

     Creating a file
Command:            cat
(a) Syntax:         $cat > File name
Function:           It is used to create a file. After creating a file enters the text in a
                    file and press <ctrl-d> to save a file.
(b) Syntax:         $cat > File name
Function            It is used to concatenate the new contents with the previous
                    contents of the file.
(c) Syntax:         $cat File name
Function:           This command is used to display the contents of a file.




                                                                                              7

 B.I.M.T.A.S
    Copying files
Command:             cp (copy one file to another)
Syntax:              $cp <source file name> <target file name>
Function:            It creates duplicate files
Cp overwrites without warning the destination file exists
Switches:            $cp-i <source file name> <target file name>
Where I stand for interactive
Function:            “Overwrite target file?”
                     If user press y then it will overwrite the existing file


    Removing files
Command:             rm (remove file)
Syntax:              $rm file name
Function:            It will remove files.
We can also delete multiple files with this command
Switches:
Syntax:              $rm – i file name
Where I stand for interactive
Function:            It will ask the user for confirmation before removing any file.
Syntax:              $rm - r filename
Where r stand for recursive
Function:            This will remove all the files and subdirectories from the current
directory.

    Renaming files
Command:             mv
Syntax:              $mv <old name> <new name>
Function:            It will changes the name of the files or directory/moves files one
                     directory to another.
Switches:
Syntax:              $mv-i
Where I stand for interactive
Function:            It will ask for confirmation.

                                                                                          8

 B.I.M.T.A.S
    Listing
Command:            ls
Syntax:             ls file name
Function:           It is used when a particular file is to be searched if the file is not
                    found it displays the message that no such file or directory exists.
Syntax:             $ls
Function:           It will display the list of files and sub-directories in the pwd.
Switches :
Syntax:             $lr-r
Function:           It will display the names of file and directories to be listed in
Reverse order.
Syntax:             $ls-i
Function:           It displays list along with attributes of file.
Syntax:             $ls-x
Function:           It displays multi-columnar output.


    Counting words
Command:         wc (word count)
Syntax:          $wc file name
Function:        It will count lines, characters and words in a file.

    Comparing files
Command:         cmp (compare)
Syntax:          $cmp <file name1> <file name2>
Function:        It will compare two files.

    Displaying date
Command:          date
Syntax:           $date
Function:         It will display the system date


                                                                                             9

 B.I.M.T.A.S
Format specifiers
          “+%m”
           It will display only the month.
          “+%h”
           It will display only the month name.
           User can also combine “+%h%m” in one command.
          “+%d”
           It will display the date of month.
          “+%y”
           It will display the last two digits of the year.
          “+H”,”+%M”,”+%S”
           It will display hour, minute, second respectively
           .
    Displaying messages
Command:            echo
Syntax:             $echo “message”
Function:           It will display the message on the screen.

    Displaying name of the machine
Command:          uname (user name)
Syntax:           $uname
Function:         It will show the name of the user’s machine.
Switches:
Syntax:           $uname-n


    Displaying calendar
Command:           cal (calendar)
Syntax:           $cal year
Function:         It will display the calendar of the specified year.

    Banner
Command:            banner
Syntax:             $banner ‘text”

                                                                        10

 B.I.M.T.A.S
Function:            It creates posters by blowing up its arguments.

    Who
Command:             who
Syntax:              $who
Function:            It will display the list of current users of the system.
Syntax:              $who am I
Function:            It will show the login detail pertaining to the user of the system.

    Calculator
Command:             bc
Syntax:              $bc
Function:            It will display the current work directory.

    Present work directory
Command:         pwd
Syntax:          $pwd
Function:        It will display the current work directory.

    Displaying root directory
Command:          home
Syntax:           $echo $home
Function:         It will display user’s home directory.

    Displaying the manual pages
Command:          man
Syntax:           $man
Function:         It will display pages from the UNIX reference manual

    Searching string in file
Command:          grep
Syntax:           $grep string file name
Function:         Every line in the file that contains given string is displayed.


                                                                                           11

 B.I.M.T.A.S
1. PROGRAM TO SWAP TWO NUMBERS.


echo “enter 2 no’s”
read a
read b
temp=$a
a=$b
b=$temp
echo “no’s after swapping are” $a,$b




Output:-
enter 2 no’s
5
6
no’s after swapping are
6
5
                                       12

B.I.M.T.A.S
2. PROGRAM TO FIND GReATEST AMONG TWO NUMBERS.


echo “enter first number”
read x
echo “enter second number”
read y
if test $x –gt $y
then
echo “$x is greater then $y”
else
echo “$x is not greater than $y”
fi


Output:-
enter first number
5
enter second number
8
8 is greater than 5
                                                 13

B.I.M.T.A.S
3. PROGRAM TO FIND GREATEST AMONG THREE NUMBERS.


echo “enter the first number”
read x
echo “enter the second number”
read y
echo “enter the third number”
read z
if test $x –gt $y –a $x –gt $z
then echo “$x is greatest”
else
if test $y –gt $x –a $y –gt $z
then
echo “$yis greatest”
else
if test $z –gt $x –a $z –gt $y
then
echo “$z is greatest”
fi
                                               14

B.I.M.T.A.S
fi
fi




Output:-
enter the first number
7
enter the second number
8
enter the third number
9
9 is greatest.




                          15

B.I.M.T.A.S
4. PROGRAM TO FIND WHETHER THE NUMBER IS EVEN OR
ODD.


echo “enter the number”
read n
e=`expr$n %2`
if test $e –eq 0
then
echo “noumber is even”
else
echo “number is odd”
fi




Output:-
enter the number
4
number is even


                                                   16

B.I.M.T.A.S
5. PROGRAM TO FIND THE FACTORIAL OF A NUMBER.


n=0
on=0
fact=1
echo “enter the number to find the factorial”
read n
on=$n
while [ $n –ge 1 ]
do
fact=`expr $fact \*$n`
n=`expr $n -1`
done
echo “factorial for $ no is $fact”


Output:-
enter the number to find the factorial
4
factorial for 4 is 24
                                                17

B.I.M.T.A.S
6. PROGRAM TO FIND WHETHER THE ENTERED YEAR IS
LEAP OR NOT.


year=0
echo “enter the year to check whether it is leap or not”
read year
ans=`expr $year % 4`
if [$ans –eq 0]
then
echo “$year is leap year”
else
echo “$year is not leap year”
fi


Output:-
enter the year to check whether it is leap year or not
2011
year is not leap year


                                                           18

B.I.M.T.A.S
7. PROGRAM TO FIND THE FABONACCI SERIES UPTO GIVEN
LIMIT.


echo “enter limit”
read n
f1=0
f2=1
echo $f1
echo $f2
n=`expr $n -2`
while [ $n –ne 0 ]
do
f3= `expr $f1 + $f2`
f1=$f2
f2=$f3
echo $f3
n=`expr $n -1`
done


                                                 19

B.I.M.T.A.S
Output:-
enter limit 5
0
1
1
2
3




                20

B.I.M.T.A.S
8. PROGRAM TO FIND THE TABLE OF A GIVEN NUMBER.


echo “enter the number”
read n
i=1
while [ $i –le 10 ]
do
p=`expr $n \ * $i`
echo $n “*” $i “=” $p
i=`expr $i +1`
done




                                                  21

B.I.M.T.A.S
Output:-
enter the number 2
2*1=2
2*2=4
2*3=6
2*4=8
2*5=10
2*6=12
2*7=14
2*8=16
2*9=18
2*10=20




                     22

B.I.M.T.A.S
9. PROGRAM TO FIND THE REVERSE OF A NUMBER.


echo “enter a number”
read n
rev=0
sd=0
while [ $n –gt 0 ]
do
sd=`expr $n %10`
rev=`expr $rev \*10 + $sd`
n=`expr $n / 10`
done
echo “reverse number is $rev”


Output:-
enter a number
21
reverse number is 12


                                              23

B.I.M.T.A.S
10. PROGRAM TO FIND THE SUM OF DIGITS OF A GIVEN
NUMBER.


echo “enter n digit number”
read n
sum=0
sd=0
while [ $n –gt 0 ]
do
sd=`expr $n %10`
sum=`expr $sum + $sd`
n=`expr $n /10`
done
echo “sum of digits of number is $sum”


Output:-
enter n digit number
4563
sum of digit of number is 18
                                                   24

B.I.M.T.A.S
11. PROGRAM TO FIND WHETHER THE GIVEN NUMBER IS
PALINDROME OR NOT.


echo “enter the number”
read n
sd=0
rev= “ ”
on=$n
while [ $n –gt 0 ]
do
sd= $(($n % 10))
n=$(($n / 10))
rev=$(echo ${rev}${sd})
done
if [ $on –eq $rev ]
then
echo “number is palindrome”
else
echo “number is not palindrome”
                                                  25

B.I.M.T.A.S
fi




Output:-
enter the number
121
number is palindrome




                       26

B.I.M.T.A.S
12. PROGRAM TO FIND WHETHER THE GIVEN NUMBER IS
PRIME OR NOT.


echo “enter a number”
read num
i=2
while [ $i -lt $num ]
do
if [ `expr $num % i` -eq 0 ]
then
echo “$num is not prime”
echo “since it is divisible by $i”
exit
fi
i=`expr $i +1`
done
echo “$num is a prime number”




                                                  27

B.I.M.T.A.S
Output:-
enter a number
5
5 is a prime number




                      28

B.I.M.T.A.S
13. PROGRAM TO PRINT THE PATTERN OF STARS.


echo “ see the following pattern of stars”
for ((i=1;i<=5;i++))
do
for ((j=1;j<=1;j++))
do
echo –n”*”
done
echo “ ”
done


Output:-
*
**
***
****
*****


                                             29

B.I.M.T.A.S
14. PROGRAM TO PRINT THE PATTERN OF NUMBERS.


echo “see the following pattern of numbers”
for((i=1;i<=5;i++))
do
for((j=1;j<=i;j++))
do
echo –n “$”
done
echo “ ”
done


Output:-
1
12
123
1234
12345


                                               30

B.I.M.T.A.S
15. PROGRAM TO FIND WHETHER THE GIVEN NUMBER IS
ARMSTRONG OR NOT.


echo “enter the number”
read n
q=$n
a=0
while [ $q –gt 0]
do
r=`expr $q % 10`
q=`expr $q /10`
a=`expr $a + $r \* $r\* $r`
done
if test $a –eq $n
then
echo “the number $n is armstrong number”
else
echo “the number $n is not armstrong number”
fi
                                                  31

B.I.M.T.A.S
Output:-
 enter the number
153
the number 153 is armstrong number




                                     32

B.I.M.T.A.S

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:9
posted:1/23/2012
language:simple
pages:31