IT OS Commads

Embed Size (px)

Citation preview

  • 7/31/2019 IT OS Commads

    1/69

  • 7/31/2019 IT OS Commads

    2/69

    IT_140702Operating systems

    1) telnetDESCRIPTION: - The telnet command is usedto communicate with another host

    using the TELNET protocol.SYNTAX: -telnet [host IP]

    EXAMPLE: -For CEIT Linux Server Usefollowing IP

    telnet 10.0.0.1OR

    telnet 172.16.0.2112) loginDESCRIPTION: - login is used when signingonto a system.

    SYNTAX: - login [name]EXAMPLE: - login: os07it001

    Password: ****

    3) adduserDESCRIPTION:-Create a new user or updatedefault new user information.

    SYNTAX: - $ adduser [username]EXAMPLE: - $adduser Gaurav

    OUTPUT: - New user added successfully.

    Prepared By: Page 2 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    3/69

    IT_140702Operating systems

    4) passwdDESCRIPTION: - passwd is used to update auser authentication token.

    After you create a new user withadduser command, passwd is used toset new password.

    SYNTAX: - passwd [username]EXAMPLE: - $ adduser gaurav

    $ passwd gauravChanging password for user gauravNew Password: ****

    passwd: all authenticationtokens updated successfully.

    5) manDESCRIPTION: - It provides help on variouscommands.

    SYNTAX: - $man [Command Name]EXAMPLE: - $man telnet

    6) lognameDESCRIPTION: - Print users login name.

    SYNTAX: - $lognameOUTPUT: - os07it001

    Prepared By: Page 3 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    4/69

    IT_140702Operating systems

    7) unameDESCRIPTION: - Print system information

    SYNTAX: - $unameOUTPUT: - Linux

    8) whoDESCRIPTION: - The "who" command lets youdisplay the users that are currently .logged into your UNIX computer system

    SYNTAX: - $whoThe general format for output is:

    [login name] [device name of the respectiveterminal] [date and time of login] [IP of therespective terminal]

    OUTPUT: -neha pts/0 Jun 17 14:25[172.16.0.34]

    chandni pts/1 Jun 17 15:25[172.16.0.35]

    9) who am iDESCRIPTION:-Shows who is logged in.

    SYNTAX: - $who am iOUTPUT: - neha pts/0 Jun 17 14:25

    [172.16.0.34]Prepared By: Page 4 of 69

    Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    5/69

    IT_140702Operating systems

    10) ttyDESCRIPTION:- Print the file name of the terminal connected to standardinput.

    SYNTAX: - $ ttyOUTPUT: - /dev/pts/

    11) dateDESCRIPTION: - date command displays thetime and date. The super-user can use it to

    set the system clock.SYNTAX: - $dateOUTPUT: - Fri Jul 27 14:12:06 EDT

    2007Formatting of Data:-To format a date provide a string beginning with+ .

    EXAMPLE: - $date +%bOUTPUT: - Jan

    [%b option only display current month]

    Other Formats specifiers are as follows:-

    Prepared By: Page 5 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    6/69

    IT_140702Operating systems

    Specifier Description Values/Example

    Day

    %aweekday,abbreviated Wed

    %A weekday, full Wednesday

    %dday of themonth (dd),zero padded

    17

    %e day of themonth (dd) 17

    %jday of year,zero padded 000-366

    %uday of week starting withMonday (1),i.e. mtwtfss

    3

    Prepared By: Page 6 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    7/69

    IT_140702Operating systems

    %w

    day of week starting with

    Sunday (0),i.e. smtwtfs

    3

    %Uweek number Sunday as firstday of week

    053

    Week

    %W

    week number Monday asfirst day of week

    053

    %Vweek of theyear 053

    Month

    %m mm month 06

    Prepared By: Page 7 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    8/69

    IT_140702Operating systems

    %h Mon Jun

    %b Mon, locale'sabbreviated Jun

    %Blocale's fullmonth,variable length

    June

    Year

    %yyy two digityear 0099

    %Y ccyy year 2009

    %g

    2-digit year correspondingto the %V

    week number

    %G 4-digit year corresponding

    Prepared By: Page 8 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    9/69

    IT_140702Operating systems

    to the %Vweek number

    Century

    %C cc century 0099

    Date

    %D mm/dd/yy 06/17/09

    %xlocale's daterepresentation

    (mm/dd/yy)

    06/17/2009

    %F %Y-%m-%d

    Hours

    %l(Lowercase L)

    hour (12 hour clock) 9

    Prepared By: Page 9 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    10/69

    IT_140702Operating systems

    %I(Uppercas

    e I)

    hour (12 hour clock) zero

    padded

    09

    %k hour (24 hour clock) 21

    %Hhour (24 hour clock) zero

    padded21

    %p

    locale's upper case AM or PM (blank inmany locales)

    PM

    %Plocale's lower case am or pm(really!)

    pm

    Minutes

    %M MM minutes 19

    Prepared By: Page 10 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    11/69

    IT_140702Operating systems

    Seconds

    %sseconds since00:00:001970-01-01UTC

    1245273549

    %S SS second

    0060(The 60 is necessaryto accommodate aleap second)

    %N nanoseconds 000000000 999999999

    Time

    %r

    hours,minutes,

    seconds (12-hour clock)

    09:19:09 PM

    %R hours, minutes hh:mm e.g. 21:19

    Prepared By: Page 11 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    12/69

    IT_140702Operating systems

    (24 hour clock)

    %T

    hours,minutes,seconds (24-hour clock)

    21:19:09

    %Xlocale's timerepresentation(%H:%M:%S)

    Date and Time

    %clocale's dateand time

    Sat Nov 04 12:02:33EST 1989

    Time zone

    %z-zzzz RFC-822 stylenumerictimezone

    -0500

    Prepared By: Page 12 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    13/69

    IT_140702Operating systems

    %Z

    time zone(e.g., EDT)

    nothing if notime zone isdeterminable

    EST

    12) calDESCRIPTION: - cal displays a simplecalendar. If arguments are not specified, the

    current month is displayed.The options are as follows

    SYNTAX: - $ calOUTPUT: - October 2008

    Su Mo Tu We Th FrSa

    1 2 34

    5 6 7 8 9 1011

    12 13 14 15 16 1718

    19 20 21 22 23 2425Prepared By: Page 13 of 69

    Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    14/69

  • 7/31/2019 IT OS Commads

    15/69

    IT_140702Operating systems

    14) mkdirDESCRIPTION: - Create the DIRECTORY, if itdoes not already exist.

    SYNTAX: - $mkdir [directory name]EXAMPLE: - $ mkdir neha

    NOTE: If you want to check whether directoryis created or not use ls command.

    15) cdDESCRIPTION: - cd is used to changedirectory.

    EXAMPLE: - $ cd neha

    16) cd..DESCRIPTION: - To come out of currentworking directory

    17) pwdDESCRIPTION: - Use this command to find outwhat directory you are working in.

    EXAMPLE: - $pwdOUTPUT: - /home/oso7it001/neha.

    18) rmdirDESCRIPTION: - Deletes a empty directory.Prepared By: Page 15 of 69

    Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    16/69

    IT_140702Operating systems

    EXAMPLE: - $rmdir nehaThe above command removes the directoryneha.To check whether directory is deleted or not usels command.You can also delete more than one directory inone shot.

    File Commands:-19) touchDESCRIPTION: - Touch command is used tocreate empty file. Its size is 0 bytes. It

    will not allow user to write anythingin file. Using touch command you canalso create multiple files at a time.

    EXAMPLE: - $ touch f1 f2 f3 f4This command will create four empty file asstated above.

    20) catDESCRIPTION: - This is one of the mostflexible UNIX commands. We can use to

    create, view and concatenate files. For our first example we create a three-

    Prepared By: Page 16 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    17/69

    IT_140702Operating systems

    item English-Spanish dictionary in afile called "dict."

    EXAMPLE:-$ cat >dict[Enter data into file]

    red rojogreen verdeblue azul

    Above, stands for "hold the controlkey down, then tap 'd'". The symbol > tells thecomputer that what is typed is to be put into thefile dict. To view a file we use cat in a differentway:

    $ cat dictOUTPUT:-

    red rojogreen verdeblue azul

    If we wish to add text to an existing file we dothis:

    $ cat >>dictwhite blancoblack negro

    Prepared By: Page 17 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    18/69

    IT_140702Operating systems

    Now suppose that we have another file tmpthat looks like this:

    $ cat tmpcat gatodog perro

    Then we can join dict and tmp like this:$ cat dict tmp >dict2

    21) rmDESCRIPTION: - rm (short for remove ) is aUNIX command used to delete files from a

    file system.EXAMPLE:-$ rm dict

    To check whether file is deleted or not use lscommand.

    Common options that rm accepts include: -r, which removes directories, removing the

    contents recursively beforehand (so as not toleave files without a directory to reside in)("recursive")

    -i, which asks for every deletion to beconfirmed ("interactive")

    Prepared By: Page 18 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    19/69

    IT_140702Operating systems

    -f, which ignores non-existent files andoverrides any confirmation prompts("force")

    -v, which shows what is being removed as ithappens ("verbose")

    EXAMPLE:- $rm v dict OUTPUT: - removed dict

    To create a hidden file, file name should beginwith. (dot)EXAMPLE:-$ cat > .f1When you give ls command hidden file wouldnot be visible.

    22) cpDESCRIPTION: - cp is the command entered ina UNIX shell to copy a file from one

    place to another. The original file

    remains unchanged, and the new filemay have the same or a differentname.

    To copy a file to another file:-Prepared By: Page 19 of 69

    Neha Shah (I.T)Chandni Shah (I.T)

    http://en.wikipedia.org/wiki/Command_(computing)http://en.wikipedia.org/wiki/Unix_shellhttp://en.wikipedia.org/wiki/Computer_filehttp://en.wikipedia.org/wiki/Unix_shellhttp://en.wikipedia.org/wiki/Computer_filehttp://en.wikipedia.org/wiki/Command_(computing)
  • 7/31/2019 IT OS Commads

    20/69

    IT_140702Operating systems

    SYNTAX: - $ cp [Source File] [TargetFile]

    To copy a file to a directory$ cp [Source File] ... [Target

    Directory]To copy a directory to a

    directory$ cp [Source Directory] ...

    [Target Directory]

    23) mvDESCRIPTION: - mv (short for move) is aUNIX command that moves one or more

    files or directories from one place toanother. The original file is

    deleted, and the new file may havethe same or a different name. If

    possible (i.e. when the original andnew files are on the same

    file system), mv will rename thefile instead. Write permission is

    required on all directories beingmodified

    Prepared By: Page 20 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    21/69

    IT_140702Operating systems

    SYNTAX: - mv [myfile][mynewfilename]

    The above command renames thefile.

    24) lnDESCRIPTION: - ln is a standard UNIXcommand used to create links ( link) to files

    Links allow more than one filename to refer to the same file

    SYNTAX: - ln [file_name] [link_name]

    25) lsDESCRIPTION: - "ls" stands for list. It is usedto list information about files and

    directories.EXAMPLES:-

    $ ls DESCRIPTION: - This is the basic "ls"command, with no options. It provides a very

    basic listing of the files in your current working directory. Filenames

    Prepared By: Page 21 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    22/69

    IT_140702Operating systems

    beginning with a decimal areconsidered hidden files, and they are

    not shown.OUTPUT: - Neha chandni f1 f2

    $ls -a DESCRIPTION: -The -a option tells the lscommand to report information about all files,

    including hidden files.

    $ls -l DESCRIPTION: -The -l option tells the "ls"command to provide a long listing of

    It is used in UNIX long directorylistings. It consists of 10 characters.

    The first character shows the filetype. Next 9 characters are

    permissions, consisting of threegroups: owner, group, others. Each

    group consists of three symbols: rwx(in this order), if some permission

    Is denied, then a dash "-" is usedinstead.

    Prepared By: Page 22 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    23/69

    IT_140702Operating systems

    EXAMPLE: - - rwxr--r--0123456789

    Symbol in the position 0 ("-") is the type of thefile. It is either "d" if the item is a directory or "l" if it is a link or "-" if the item is a regular file.Symbols in positions 1 to 3 ("rwx") are

    permissions for the owner of the file.Symbols in positions 4 to 6 ("r--") are

    permissions for the group.Symbols in positions 7 to 9 ("r--") are

    permissions for others.r Read access is allowedw Write access is allowedx Execute access is allowed

    - Replaces "r", "w" or "x" if according accesstype is denied

    Examples:

    -rwxr-xr-x

    File,owner has read, write, execute

    permissions,group: only read and execute

    permissions,Prepared By: Page 23 of 69

    Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    24/69

    IT_140702Operating systems

    others: only read and execute permissions.

    dr-x------ Directory,owner has read and execute access,group and others have no access

    EXAMPLE: - $ ls -ltotal 16 [total no of blocks occupied on the harddisk]

    Permission

    Noof owner

    OwnerNa

    me

    GroupName

    Size

    TimeOf Creation

    File/Directory

    -rw-rw-r--

    2 chandni

    chandni

    24 Jun1814:30

    file1

    -rw-rw-r--

    2 chandni

    chandni

    24 Jun1814:30

    file2

    -rw-rw-r--

    1 chandni

    chandni

    37 Jun1814:30

    file3

    -rw-rw-r--

    1 chandni

    chandni

    0 Jun18

    n3

    Prepared By: Page 24 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    25/69

    IT_140702Operating systems

    11:12Drwxr wxr-x

    2 chandni

    chandni

    4093

    Jun1814:30

    Neha

    26) chmodDESCRIPTION: - To change permissions on aUNIX file use the chmod

    chmod command is use To set/modifya file or directorys permissions of course, only the owner of a file mayuse chmod to alter a file's permissions.chmod has the following

    SYNTAX :- chmod [options] mode file(s)

    There are two types of modes available:-

    1. String modes :-

    Reference Class DescriptionU user the owner of the fileG group users who are members of thePrepared By: Page 25 of 69

    Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    26/69

    IT_140702Operating systems

    file's group

    O others

    users who are not the owner of

    the file or members of thegroup

    A all all three of the above, is thesame as ugo

    The chmod program uses an operator to specify

    how the modes of a file should be adjusted. Thefollowing operators are accepted:

    Operator Description

    + adds the specified modes to thespecified classes

    - removes the specified modes from thespecified classes

    = the modes specified are to be made theexact modes for the specified classes

    String mode examples:-

    For example, the following command would beused to add the read and write permissions to thePrepared By: Page 26 of 69

    Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    27/69

    IT_140702Operating systems

    user and group classes of a file or directorynamed sample$ chmod ug+rw sample$ ls -ld sampledrw-rw---- 2 unixguy unixguy 96 Dec 812:53 sample

    2. Octal numbers

    The chmod command also accepts three andfour-digit octal numbers representing modes.See the article mentioned above for moreinformation. Using a four-digit octal number toset the modes of a file or directory namedsample would look something like this:

    Permission weight

    Read (r) 4Write (w) 2Execute 1

    $ chmod 0664 sampleAssuming that the setuid, setgid and sticky bitsare not set, this is equivalent to$ chmod 664 samplePrepared By: Page 27 of 69

    Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    28/69

    IT_140702Operating systems

    or $ chmod +r,-x, ug+w sample

    27) umask DESCRIPTION: - Umask is use to decide thedefault permission.It stands for user file

    creation mask, mask implyingwhich permission to mask or hide.

    The umask value tells UNIX whichof three permission are to be

    denied rather than granted.$touch sample$ ls l sample-rw-rr 1 chandni chandni 24 Jun 18 14:30sample.The current value of umask can be easilydetermined by just typing umask

    EXAMPLE: - $ umask OUTPUT: - 0022

    Here, the first 0 indicate that what follows is anoctal number. The three digits that follow thefirst zero refer to the permission to be denied tothe owner, group and others. This means that for Prepared By: Page 28 of 69

    Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    29/69

    IT_140702Operating systems

    the owner no permission is denied, whereas for both the group and others write permission (2) isdenied. Whenever a file is created UNIXassumes that the permissions for this file should

    be 666.Burt since our umask value is 022, UNIXsubtracts this value from the default system wide

    permission (666) resulting in a value (644).Thisvalue is then used as the permission for the filethat you create.That is the reason why the permissions turnedout to be 644 or rw-rrfor the sample file.Similarly system wide default permission for adirectory are 777.This means that when wecreate a directory its permissions would be 777 022 i.e. 755.execute permission for a directoryhas a special significance. If a directory doesnthave an execute permission we can never enter into it.

    We can change the current umask.EXAMPLE:- $umask 242Here onwards new file have permission 424(666- 242).ans directory permission 535 (777-242)

    Prepared By: Page 29 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    30/69

    IT_140702Operating systems

    Miscellaneous Commands

    Filter Commands:-

    28) head

    DESCRIPTION: - head command displays first10 lines in the file.

    SYNTAX: - $ head [file name]EXAMPLE: - $head neha

    Note: It will display first 10 lines of the file.

    29) tailDESCRIPTION: -tail command displays last 10lines in the file.

    SYNTAX: - $ tail [file name]EXAMPLE: - $ tail neha

    Note: It will display last 10 lines of the file.

    For both head and tail command in order todisplay either first n or last n no of linesrespectively, use OPTION nPrepared By: Page 30 of 69

    Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    31/69

    IT_140702Operating systems

    EXAMPLE: - $ head -3 nehaIt will display first 3 lines of neha

    file.EXAMPLE: - $tail -3 neha

    It will display last 3 lines of nehafile.

    30) cutDESCRIPTION: -The external cut command

    displays selected columns or fields fromeach line of a file

    Cut can work in two modes:1. column delimited selection (each column

    starts with certain fixed offset defined asrange from -to)

    cut identifies both columns and fields.$ cat > file1

    Neha lecturer osChandni lecturer osHinal lecturer JavaThe c option cutting columns.Example $ cut c 1 - 7, 19 -20 file1OUTPUT:-

    Neha osPrepared By: Page 31 of 69

    Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    32/69

    IT_140702Operating systems

    Chandni osHinal Java

    2. Separator-delimited selection (with columnseparator being a single character like blank,comma, colon, etc). In this mode cut uses adelimiter defined by -d option (as inexample above). By default cut uses thevalue of delimiter stored in a shell variablecalled IFS (Input Field Separators) --typically TAB.

    The f option for cutting fields. Along with f option you have to user d (delimiter) for the field delimiter.

    $ cat > file2 Neha | lecturer | os

    Chandni | lecturer | osHinal | lecturer |Java

    EXAMPLE: - $ cut d | f 2, 3 file2OUTPUT:- lecturer | os

    lecturer | oslecturer |Java

    Prepared By: Page 32 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    33/69

    IT_140702Operating systems

    31) pasteDESCRIPTION: -It vertically merges lines of files.

    SYNTAX: - paste [OPTION]... [FILE]...EXAMPLE: - [Enter the Data of file 1]

    $cat >f1NehaPatel

    [Enter the Data of file 1]

    $cat >f2ChandniShah

    $ paste f1 f2OUTPUT: - Neha chandni

    Patel shahOPTIONS: - You can specify a delimiter of

    your choice with the d optionEXAMPLE: - $ paste d \: f1 f2

    OUTPUT: - Neha: ChandniPatel: Shah

    Prepared By: Page 33 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    34/69

    IT_140702Operating systems

    32) sortDESCRIPTION:-Write lines consisting of thesequentially corresponding lines from

    each FILE, separated by Tabs, tostandard output. With no FILE,

    Or when FILE is -, read standardinput.

    OPTIONS:-1.-d, --delimiters=LIST

    reuse characters from LIST instead of Tabs

    2.-s, --serialpaste one file at a time instead of in

    parallel

    SYNTAX:- sort [-b] [-d] [-f] [-i] [-m] [-M] [-n] [-r] [-u][+fields] filename [-o outputfile]

    -b Ignores spaces at beginning of thePrepared By: Page 34 of 69

    Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    35/69

    IT_140702Operating systems

    line.-d Uses dictionary sort order and ignores

    the punctuation.-f Ignores caps-i Ignores nonprinting control

    characters.-m Merges two or more input files into

    one sorted output.-M Treats the first three letters in the line

    as a month (such as may.)-n Sorts by the beginning of the number

    at the beginning of the line.-r Sorts in reverse order -u If line is duplicated only display once+fields Sorts by fields , usually by tabsfilename The name of the file that needs to be

    sorted.-ooutputfile

    Sends the sorted output to a file.

    EXAMPLES:-$ sort -r file.txt Would sort the file, file.txt in reverse order.Related commands

    Prepared By: Page 35 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    36/69

  • 7/31/2019 IT OS Commads

    37/69

    IT_140702Operating systems

    34) trDESCRIPTION:-tr stands for Translatingcharacters.

    UNIX tr command copies the standardinput to the standard output withsubstitution or deletion of selectedcharacters. In addition it can squeezerepeating characters into a singecharacter (with option -s).

    The format of the tr command issomewhat strange -- this is one of thefew Unix commands that accepts inputonly from standard input.

    SYNTAX: - tr [options] [set1 [set2]]

  • 7/31/2019 IT OS Commads

    38/69

    IT_140702Operating systems

    Utility performs classic alphabet1 to alphabet2type of translation sometimes called 1:1transliteration and as such is suitable for implementation of Caesar cipher . UNIXinherited tr from Multix as a derivative of PL/1translate built-in, which in turn was ageneralization of a TR command in System/360architecture

    Sets can be specified by enumeration of characters like in tr '{}' '()' < infile > outfile) or using ranges like in tr 'A-Z' 'a-z' < infile >outfile. Special POSIX character classes can beused:

    alnum : alphanumeric charactersalpha : alphabetic characterscntrl : control (non-printing) charactersdigit : numeric charactersgraph : graphic characterslower : lower-case alphabetic charactersprint : printable characterspunct : punctuation charactersspace : whitespace charactersupper : upper-case charactersPrepared By: Page 38 of 69

    Neha Shah (I.T)Chandni Shah (I.T)

    http://en.wikipedia.org/wiki/Caesar_cipherhttp://en.wikipedia.org/wiki/Caesar_cipher
  • 7/31/2019 IT OS Commads

    39/69

    IT_140702Operating systems

    xdigit : hexadecimal characters

    Typical usage of classes involves changing thecase from upper to lower or vise versa like in thefollowing example:

    cat >f1HI HELLO

    NEHA CHANDNI$ tr '[: upper:]' '[: lower:]' < f1

    OUTPUT:-hi helloneha chandni

    Classes can be combined to form a morecomplex set, for example '[: lower:] [: upper:]'The tr utility accepts several options:-d delete characters in the first set from theoutput-d , --delete Delete specified set of charactersdefined in set1 but do not translate.For example:cat > f1Hi; helloPrepared By: Page 39 of 69

    Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    40/69

    IT_140702Operating systems

    134 / 12

    EXAMPLE: - tr -d '; /' < f1OUTPUT: - Hi hello

    134 12

    [: alnum:] -- All letters and digits[: alpha:] -- All letters[: blank:] -- All horizontal whitespace[: cntrl:] -- All control characters[: digit:] -- All digits[: graph:] -- All printable characters, notincluding space[: lower:] -- All lower case letters[: print:] -- All printable characters, includingspace[: punct:] -- All punctuation characters[: space:] -- All horizontal or vertical whitespace[: upper:] -- All upper case letters

    35) grepThe grep command allows you to search for aspecified pattern in one or more files, printingany lines which contain the specified pattern.

    Prepared By: Page 40 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    41/69

    IT_140702Operating systems

    The syntax for the grep command is:grep [options] pattern [files]

    OPTIONS:-

    -b Display the block number at the beginning of each line.-c Display the number of matched lines.

    -h Display the matched lines, but do not displaythe filenames.-i Ignore case sensitivity.

    -l Display the filenames, but do not display thematched lines.

    -n Display the matched lines and their linenumbers.-s Silent mode.-v Display all lines that do NOT match.-w Match whole word.

    EXAMPLES:-grep -c tech file1

    Exit StatusPrepared By: Page 41 of 69

    Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    42/69

    IT_140702Operating systems

    This command returns the following exit values:0 A match was found.1 No match was found.

    >1A syntax error was found or a file wasinaccessible (even if matches were found).

    EXAMPLES:-To use a pattern that contains some of the

    pattern-matching characters *, ^,?, [,], \(, \), \{,and \}, enter:grep ^[a-zA-Z]" pgm.sThis displays every line in pgm.s whose firstcharacter is a letter.To display all lines that do not match a

    pattern, enter:grep -v "^#" pgm.s

    This displays every line in pgm.s whose firstcharacter is not a # (pound sign).

    To display all lines in the file1 file that match

    either the abc or xyz string, enter:grep -E "abc|xyz" file1

    36) cmpPrepared By: Page 42 of 69

    Neha Shah (I.T)Chandni Shah (I.T)

    http://publib.boulder.ibm.com/infocenter/systems/topic/com.ibm.aix.cmds/doc/aixcmds2/grep.htm#a133z91f5chttp://publib.boulder.ibm.com/infocenter/systems/topic/com.ibm.aix.cmds/doc/aixcmds2/grep.htm#qv72370bobhttp://publib.boulder.ibm.com/infocenter/systems/topic/com.ibm.aix.cmds/doc/aixcmds2/grep.htm#a133z91f5chttp://publib.boulder.ibm.com/infocenter/systems/topic/com.ibm.aix.cmds/doc/aixcmds2/grep.htm#qv72370bob
  • 7/31/2019 IT OS Commads

    43/69

    IT_140702Operating systems

    DESCRIPTION: - cmp is a command line utilityfor computer systems that use UNIX or

    a Unix-like operating system .It compares two files of any type and

    writes the results to the standardoutput . By default, cmp is silent if the

    files are the same; if they differ, the byte and line number at which the

    first difference occurred is reported.

    cmp may be qualified by the use of thefollowing command-line switches , (the longversions are in brackets):

    1)-b, --print-bytes Print differing bytes.2)-i SKIP, --ignore-initial=SKIP Skip the first SKIP bytes of input.

    3)-i SKIP1:SKIP2, --ignore-initial=SKIP1:SKIP2

    Skip the first SKIP1 bytes of FILE1 and the firstSKIP2 bytes of FILE2.4)-l, --verbose

    Prepared By: Page 43 of 69 Neha Shah (I.T)Chandni Shah (I.T)

    http://en.wikipedia.org/wiki/Command_linehttp://en.wikipedia.org/wiki/Computerhttp://en.wikipedia.org/wiki/Unixhttp://en.wikipedia.org/wiki/Unix-likehttp://en.wikipedia.org/wiki/Operating_systemhttp://en.wikipedia.org/wiki/Computer_filehttp://en.wikipedia.org/wiki/Standard_outputhttp://en.wikipedia.org/wiki/Standard_outputhttp://en.wikipedia.org/wiki/Bytehttp://en.wikipedia.org/wiki/Command-line_argumenthttp://en.wikipedia.org/wiki/Command_linehttp://en.wikipedia.org/wiki/Computerhttp://en.wikipedia.org/wiki/Unixhttp://en.wikipedia.org/wiki/Unix-likehttp://en.wikipedia.org/wiki/Operating_systemhttp://en.wikipedia.org/wiki/Computer_filehttp://en.wikipedia.org/wiki/Standard_outputhttp://en.wikipedia.org/wiki/Standard_outputhttp://en.wikipedia.org/wiki/Bytehttp://en.wikipedia.org/wiki/Command-line_argument
  • 7/31/2019 IT OS Commads

    44/69

    IT_140702Operating systems

    Output byte numbers and values of all differing bytes.5)-n LIMIT, --bytes=LIMIT Compare at most LIMIT bytes.6)-s, --quiet, --silent Output nothing; yield exit status only.7)-v, --version Output version info.8)--help Outputs a help file.

    Return values:-

    0 - files are identical1 - files differ 2 - inaccessible or missing argument

    37) commDESCRIPTION: - comm reads two files asinput, regarded as lines of text. comm outputs

    one file, which contains threecolumns. The first two columnscontain lines unique to the first andsecond file, respectively. The lastcolumn contains lines common to

    Prepared By: Page 44 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    45/69

    IT_140702Operating systems

    both. This functionally is similar todiff .

    EXAMPLE:-File fooapple

    bananaeggplant

    File barapple

    banana bananazucchini

    comm foo barapplebanana

    bananaeggplant

    zucchini

    Disk related Commands:-

    Prepared By: Page 45 of 69 Neha Shah (I.T)Chandni Shah (I.T)

    http://en.wikipedia.org/wiki/Diffhttp://en.wikipedia.org/wiki/Diff
  • 7/31/2019 IT OS Commads

    46/69

    IT_140702Operating systems

    38) duDESCRIPTION: - du (abbreviated from d isk u sage ) is a standard UNIX program used to

    estimate the file space usage; spaceused under a particular directory or files on a file system .

    du takes a single argument, specifying a pathname for du to work; if it is not specified,the current directory is used. The SUS mandatesfor du the following options:

    -a, display an entry for each file (and notdirectory) contained in the current directory-H , calculate disk usage for link referencesspecified on the command line-k , show sizes as multiples of 1024 bytes , not512-byte-L, calculate disk usage for link referencesanywhere-s, report only the sum of the usage in thecurrent directory, not for each file-x, only traverse files and directories on thedevice on which the pathname argument isspecified.Prepared By: Page 46 of 69

    Neha Shah (I.T)Chandni Shah (I.T)

    http://en.wikipedia.org/wiki/Unixhttp://en.wikipedia.org/wiki/Computer_programhttp://en.wikipedia.org/wiki/File_systemhttp://en.wikipedia.org/wiki/Bytehttp://en.wikipedia.org/wiki/Unixhttp://en.wikipedia.org/wiki/Computer_programhttp://en.wikipedia.org/wiki/File_systemhttp://en.wikipedia.org/wiki/Byte
  • 7/31/2019 IT OS Commads

    47/69

    IT_140702Operating systems

    -h, show filesize in human readable format.

    EXAMPLE:-sum of directories in kilobytes$ du -sk *OUTPUT:-152304 directory One1856548 directory Two

    Sum of directories in human-readable format(Byte, Kilobyte, Megabyte, Gigabyte, Terabyteand Petabyte):$ du -sh *149M directoryOne1.8G directoryTwo

    disk usage of all subdirectories and filesincluding hidden files within the currentdirectory (sorted by filesize):$ du -sk . [A-z]* *| sort -nThe weight of directories:$ du -d 1 -c -h

    39) df

    Prepared By: Page 47 of 69 Neha Shah (I.T)Chandni Shah (I.T)

    http://en.wikipedia.org/wiki/Kilobytehttp://en.wikipedia.org/wiki/Human-readablehttp://en.wikipedia.org/wiki/Sort_(Unix)http://en.wikipedia.org/wiki/Kilobytehttp://en.wikipedia.org/wiki/Human-readablehttp://en.wikipedia.org/wiki/Sort_(Unix)
  • 7/31/2019 IT OS Commads

    48/69

    IT_140702Operating systems

    DESCRIPTION:- df (abbreviation for d isk f ree )is a standard Unix computer program

    used to display the amount of available disk space for file systems on which the invoking user hasappropriate read access. df is usuallyimplemented by reading the mtab file

    OPTIONS:--k Use 1024-byte units, instead of the default512-byte units, when writing space figures.-PUse a standard, portable, output format

    -tIf XSI compliant, show allocated space aswell

    The output with -P shall consist of one line of information for each specified file system. Theselines shall be formatted as follows:

    , , , , ,

    Prepared By: Page 48 of 69 Neha Shah (I.T)Chandni Shah (I.T)

    http://en.wikipedia.org/wiki/Unixhttp://en.wikipedia.org/wiki/Computer_programhttp://en.wikipedia.org/wiki/Filesystemshttp://en.wikipedia.org/wiki/Mtabhttp://en.wikipedia.org/w/index.php?title=X/Open_System_Interfaces_Extension&action=edit&redlink=1http://en.wikipedia.org/wiki/Unixhttp://en.wikipedia.org/wiki/Computer_programhttp://en.wikipedia.org/wiki/Filesystemshttp://en.wikipedia.org/wiki/Mtabhttp://en.wikipedia.org/w/index.php?title=X/Open_System_Interfaces_Extension&action=edit&redlink=1
  • 7/31/2019 IT OS Commads

    49/69

    IT_140702Operating systems

    In the following list, all quantities expressed in512-byte units (1024-byte when -k is specified)shall be rounded up to the next higher unit. Thefields are:

    The name of the file system, in animplementation-defined format.

    The total size of the file system in 512-byteunits. The exact meaning of this figure isimplementation-defined, but should include, , plus any spacereserved by the system not normallyavailable to a user.

    The total amount of space allocated toexisting files in the file system, in 512-byte

    units.

    Prepared By: Page 49 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    50/69

    IT_140702Operating systems

    The total amount of space available withinthe file system for the creation of new files

    by unprivileged users, in 512-byte units.When this figure is less than or equal tozero, it shall not be possible to create anynew files on the file system without firstdeleting others, unless the process hasappropriate privileges. The figure writtenmay be less than zero.

    The percentage of the normally availablespace that is currently allocated to all fileson the file system. This shall be calculatedusing the fraction:

    / (+ )

    expressed as a percentage. This percentagemay be greater than 100 if is

    less than zero. The percentage value shall beexpressed as a positive integer, with anyfractional result causing it to be rounded tothe next highest integer.

    Prepared By: Page 50 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    51/69

    IT_140702Operating systems

    The directory below which the file system

    hierarchy appears.

    Process related Commands:-

    40) ps

    DESCRIPTION:-The "ps" command (active process) lets you check the status of

    processes that are running on your UNIX system.

    Note - the ps command may be slightly differenton your system, depending on the type of systemyou have. The examples shown here work onsystems derived from AT&T's original UnixSystem V ps command.

    SYNTAX: - ps [options]

    EXAMPLES:-

    ps

    Prepared By: Page 51 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    52/69

    IT_140702Operating systems

    The ps command by itself shows minimalinformation about the processes you are running.Without any arguments, this command will notshow information about other processes runningon the system.

    ps f

    The -f argument tells ps to supply full information about the processes it displays. Inthis example, ps displays full information aboutthe processes you are running.

    ps e

    The -e argument tells the ps command to showevery process running on the system.

    ps -ef

    The -e and -f arguments are normally combinedlike this to show full information about everyPrepared By: Page 52 of 69

    Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    53/69

    IT_140702Operating systems

    process running on the system. This is probablythe most often-used form of the ps command.

    ps -ef | more

    Because the output normally scrolls off thescreen, the output of the ps -ef command is often

    piped into the more command. The morecommand lets you view one screenful of information at a time.

    ps -fu fred

    This command shows full information about the processes currently being run by the user named fred (the -u option lets you specify a username).

    QUESTIONS:-

    1) What is the difference between MV and CPcommand of UNIX?

    Prepared By: Page 53 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    54/69

    IT_140702Operating systems

    2) How can we obtain just day from the datecommand?

    3) Explain different types of calculator functions.

    4) Explain cut and paste commands withexample.

    5) What is difference between internalcommand and external command?

    Practical 3

    Aim : Shell Programming .

    Prepared By: Page 54 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    55/69

    IT_140702Operating systems

    Software Required : Telnet Client facility,Linux Server

    Knowledge Required: Shell commands, Shellscripting language

    Theory / Logic:

    A shell is a command line interpreter. It takescommands and executes them. As such, itimplements a programming language. TheBourne shell can be used to create shell scripts,i.e., programs that are interpreted/ executed bythe shell. You can write shell scripts with the Cshell; however, this is not covered here.Some Basic Points about the Shell Scripts:Shell scripts are simple text files created with aneditor.Shell scripts are marked as executableShell scripts should be located in your search

    path and ~/bin should be in your search path.You likely need to rehash if you're a Csh (tcsh)user (but not again when you login).Arguments are passed from the command lineand referenced, for example, as $1.Prepared By: Page 55 of 69

    Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    56/69

    IT_140702Operating systems

    #! /bin/shAll Bourne Shell scripts should begin with thesequence

    #! /bin/shFrom the man page for exec(2):On the first line of an interpreter script,following the "#! is the name of a programwhich should be used to interpret the contents of the file. For instance, if the first line contains "#!/bin/sh", then the con- tents of the file areexecuted as a shell script.You can get away without this, but youshouldn't. All good scripts state the interpretor explicitly. Long ago there was just one (theBourne Shell) but these days there are manyinterpreters -- csh, ksh, bash, and others.CommentsComments are any text beginning with the

    pound (#) sign. A comment can start anywhereon a line and continue until the end of the line.Search PathAll shell scripts should include a search pathspecification:

    PATH=/usr/ucb:/usr/bin:/bin; export PATH

    Prepared By: Page 56 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    57/69

    IT_140702Operating systems

    A PATH specification is recommended -- oftentimes a script will fail for some people becausethey have a different or incomplete search path.The Bourne Shell does not export environmentvariables to children unless explicitly instructedto do so by using the export command.

    VI EDITOR:

    vi (pronounced vee-EYE, short for "visual") provides basic text editing capabilities. Threeaspects of vi make it appealing. First, vi issupplied with all UNIX systems. You can use viat other universities or any businesses withUNIX systems. Second, vi uses a small amountof memory, which allows efficient operationwhen the network is busy. Third, because vi usesstandard alphanumeric keys for commands, youcan use it on virtually any terminal or workstation in existence without having toworry about unusual keyboard mappings. As a

    point of interest, vi is actually a special mode of another UNIX text editor called ex. Normallyyou do not need to use ex except in vi mode.

    Prepared By: Page 57 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    58/69

    IT_140702Operating systems

    To start vi, enter:vi filename RETURN

    Saving Your Work:

    vi provides several means of saving your changes. Besides saving your work beforequitting, it's also a good idea to save your work

    periodically. Power failures or system crashescan cause you to lose work. From commandmode, you type::w RETURNto save your work ("w" is for "write"). Similarly,to quit vi use the command::q RETURNThe shell can execute commands; can have

    parameters and display messages just as if theywere type from the keyboard. In addition, filesmay use variables, like programming languages.The files which are executed by the shell arecalled shell programs or shell scripts. To create ashell script, enter the command exactly as youwould from the $ prompt into a file through aneditor.

    Prepared By: Page 58 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    59/69

    IT_140702Operating systems

    A shell script is simply a file containing shellcommands that you can execute like this: sh filename [arg1 arg2 ... argn]A shell script may also be executed by name if the file containing the shell commands has readand execute permission. If file ``do_it'' containsthe shell commands and has such permissions,then the previous example is equivalent to: do_it [arg1 arg2 ... argn]In this case, executing a shell script works thesame as executing a program. Remember that itsfirst line should be #!/bin/sh to be sure theBourne shell is the command interpreter thatreads the script.Simple Shell ScriptsThe simplest shell script contains one or morecomplete commands. For example, if youwanted to know the number of files in your current directory, you could use ls -l | wc -lIf you were to create a file called ``countf'' thatcontained this line (and with the correct read andexecute permissions), you could then count thenumber of files simply by typing:Prepared By: Page 59 of 69

    Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    60/69

    IT_140702Operating systems

    countf Any number of commands can be included in afile to create shell scripts of any complexity. For more than simple scripts, though, it is usuallynecessary to use shell variables and to make useof special shell programming commands.Shell VariablesShell variables are used for storing andmanipulating strings of characters. A shellvariable name begins with a letter and cancontain letters, digits, and underscores, such as

    xx1abc_xyz

    Shell variables can be assigned values like this:x=file1x1=/usr/man/man1/sh.1abc_xyz=4759300

    Notice that there are no spaces before or after the equals-sign. The value will be substituted for the shell variable name if the name is preceded

    by a $. For example, echo $x1would echo

    /usr/man/man1/sh.1Prepared By: Page 60 of 69

    Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    61/69

    IT_140702Operating systems

    Several special shell variables are predefined.Some useful ones are

    $#, $*, $?, and $$.Arguments can be passed to a shell script. Thesearguments can be accessed inside the script byusing the shell variables $1, $2,...,$n for

    positional parameter 1,2,...,n. The filename of the shell script itself is $0. The number of sucharguments is $#. For example, if file do_it is ashell script and it is called by giving thecommand do_it xyzthen $0 has the value do_it, $1 has the valuexyz, and $# has the value 1.$* is a variable containing all the arguments(except for $0) and is often used for passing allthe arguments to another program or script.$? is the exit status of the program most recentlyexecuted in the shell script. Its value is 0 for successful completion. This variable is useful for error handling (see section 10.6).$$ is the process id of the executing shell and isuseful for creating unique filenames. For example, cat $1 $2 >> tempfile.$$Prepared By: Page 61 of 69

    Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    62/69

  • 7/31/2019 IT OS Commads

    63/69

    IT_140702Operating systems

    exit status is nonzero, then command-list3 isexecuted.for The for command provides a looping constructof the form for shell-variable in word-list do command-list doneThe shell variable is set to the first word inword-list and then command-list is executed.The shell variable is then set to the next word inword-list and the process continues until word-list is exhausted. A common use of for -loops isto perform several commands on all (or a subset)of the files in your directory. For example, to

    print all the files in your directory, you could use for i in *

    do echo printing file $ilpr $idone

    In this case, * would expand to a list of allfilenames in your directory, i would be set toeach filename in turn, and $i would thensubstitute the filename for i (in the echo and lprcommands).Prepared By: Page 63 of 69

    Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    64/69

    IT_140702Operating systems

    while The while command provides a slightly differentlooping construct: while command-list1 do command-list2 doneWhile the exit status of the last command incommand-list1 is 0, command-list2 is executed.TestThe test command can be used to compare twointegers, to test if a file exists or is readable, todetermine if two strings are equal, or to testseveral other conditions. For example, to testwhether the value of shell variable x is equal to5, use test $x -eq 5If $x is equal to 5, test returns true.Other useful tests include test -s file (true if file exists and has a sizelarger than 0) test -w file (true if file exists and iswritable) test -z string (true if the length of string is 0) test string1 != string2

    Prepared By: Page 64 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    65/69

    IT_140702Operating systems

    (true if string1 and string2 are notidentical)The test command is often used with the flow-control constructs described above. Here is anexample of test used with the if command: if test "$1" = "" (or if ["$1" = ""] ) then

    echo usage: myname xxxxexit 1fi

    This tests to see if the command line contains anargument ( $1). If it does not ( $1 is null), thenecho prints a message.A complete list of test operators can be found inthe man page for test .

    Shell Scripts:

    1) To copy source file to destination fileusing CP Command

    2) To copy source file to destination filewithout using CP Command

    3) To append file f1 at the end of file f2.4) ) To concate content of two files.

    Prepared By: Page 65 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    66/69

    IT_140702Operating systems

    5) Write a shell script to perform realnumber of calculation and store result tothird variable.

    6) Write a shell script that works as acalculator.

    7) Checks it is a prime or not.8) Finds factorial of the given number.9) ) Finds reverse of a given number.10) ) Finds out square root of a given

    number 11) Finds the given No is Armstrong or Not.12) Fibonacci series of a given number 13) 11 + 22 + 33 + n n

    14) Write a shell script to compare twonumbers and two strings.

    15) Write a shell script that performsfollowing options: Copy, Rename, Link,Remove, Exit

    16) Checks whether entered string is a fileor a directory.

    17) Checks whether that file has write permission or not, if it has, then append dataat the end of the file.

    18) Finds no. of occurrence of a given wordin file.

    Prepared By: Page 66 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    67/69

    IT_140702Operating systems

    19) Write a shell script to find out no. of vowels form the file.

    20) Write a shell script to check validity of the user

    21) Write a shell script which displaysappropriate message according to login time.

    22) Write a shell script to find out the biggest number from the given threenumbers. Numbers are supplied as commandline argument. Print error message if sufficient arguments are not supplied.

    23) Write a shell script which will receiveany number of filenames as arguments. Theshell script should check whether everyargument supplied is a file or a directory. If it is a directory lines present in it should bedisplayed.

    24) Write a program to implement fork ()system call.

    25) Write a program to calculate standarddeviation using thread.

    Prepared By: Page 67 of 69 Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    68/69

    IT_140702Operating systems

    Questions:

    1) What is difference between commandsand shell scripts?

    2) State true or false:a. Using a for loop we can calculate

    factorial value of a number. b.A null variable A can be created using

    .c. Shell Meta character $# represents

    number of arguments supplied to theshell script.

    d.By using statement read v1 v2 v3 wecan supply only one value.

    e.Shell variables are case sensitive.3) How shell act by executing a shell

    script?4) Is there any restriction on the length of a

    shell variable?5) Can we redirect the echo stmts output

    to the file? Justify.Prepared By: Page 68 of 69

    Neha Shah (I.T)Chandni Shah (I.T)

  • 7/31/2019 IT OS Commads

    69/69

    IT_140702Operating systems

    6) Which type of shell variable is declaredfor a=1235?

    7) Which programs are compatible amongof born shell and c shell?

    8) What is the use of set command?9) Point out errors:

    a. t = 562 b.cmd = 34c.k=`expr a*b`d.3.14*$r*$r = areae.a=10

    if [$a -gt 5]then echo a is large