spsa exp 4

Upload: ankit-mittal

Post on 08-Apr-2018

231 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/7/2019 spsa exp 4

    1/25

    EXPERIMENT NO.-4

    Aim: To study UNIX commands.

    pwd

    Purpose: Short for print working directory the pwd command displays the name ofthe current working directory.

    Syntax: $ pwd

    Example:

    who

    Purpose: Tells who's logged on, and where they're coming from.

    Syntax: $ who [-option(s)]

    Options:

    -H: This option will give the heading to each column given as output by who commandand is used as

    $ who -H

    Example:

  • 8/7/2019 spsa exp 4

    2/25

    Command:who am i

    Purpose:The who am i command gives the details of the current user.

    Syntax: $ who am i

  • 8/7/2019 spsa exp 4

    3/25

    Example:

    mkdir

    Purpose: The mkdir command creates a single directory or multiple directories.

    Syntax:

    $ mkdir [Options] directories

    Options:

    -m mode Sets the access mode for the new directory.

    -p If the parent directories don't exist, this command creates them.

    -v print a message for each created directory

    Example:

  • 8/7/2019 spsa exp 4

    4/25

    cd

    Purpose: Changes the directory.

    Syntax:$ cd path of the directory to which you want to switch to

    $ cd name of subdirectory in the current directory

    Options:

    (i) cd /returns to the root directory.

    (ii) cd dir (without a /) will put you in a subdirectory.

    (iii) cd .. will move you up one directory.

    Example:

    http://www.computerhope.com/jargon/d/director.htmhttp://www.computerhope.com/jargon/d/director.htmhttp://www.computerhope.com/jargon/d/director.htm
  • 8/7/2019 spsa exp 4

    5/25

    ls

    Purpose: Using this command, the list of all subdirectories or files of the presentworking directory would be displayed. If no options are given the command willdisplay the subdirectory and file of that particular directory but the hidden files wontbe displayed. We also use this command to change the contents of a directory.

    Syntax :

    $ ls$ ls [option(s)] dir

    Options:

  • 8/7/2019 spsa exp 4

    6/25

    -a Displays all files-p Displays directories with /

    -r Displays files in reverse order

    -s Displays files sorted according to their size

    -x Displays files as rows across the screen-l Displays the long format listing.

    -C Displays files in a columnar format (default)

    -F Flags filenames

    -R Displays subdirectories as well.

    -m Displays the names as a comma-separated list.

    Example:

  • 8/7/2019 spsa exp 4

    7/25

    .

  • 8/7/2019 spsa exp 4

    8/25

  • 8/7/2019 spsa exp 4

    9/25

  • 8/7/2019 spsa exp 4

    10/25

  • 8/7/2019 spsa exp 4

    11/25

  • 8/7/2019 spsa exp 4

    12/25

  • 8/7/2019 spsa exp 4

    13/25

  • 8/7/2019 spsa exp 4

    14/25

  • 8/7/2019 spsa exp 4

    15/25

    rmdir

    Purpose: remove empty directories

    Syntax:

    $ rmdir [OPTION]... DIRECTORY...Options:

    rm -r directory - would remove a directory, even if files existed in that directory.

    rm i directory - Interactive. With this option, rm prompts for confirmation beforeremoving any files.Example:

  • 8/7/2019 spsa exp 4

    16/25

  • 8/7/2019 spsa exp 4

    17/25

  • 8/7/2019 spsa exp 4

    18/25

    cp

    Purpose: This command is used to copy 1 or more source or target files/directories. Ifread permission is not there, that file cant be copied.

    Syntax: $ cp [option] source-file destination-file

    Options:

    (i)-i: This option is used for interactive copy i.e. user will be asked beforecopying for confirmation.

  • 8/7/2019 spsa exp 4

    19/25

    (ii)-r: This option is used to copy a file recursively i.e. copy a directory alongwith its contents. It can be done by using R also.

    (iii)-v: This option will display a message that the file has been copied or not

    Example:

    mv

    Purpose: mv (short formove) moves one or more files ordirectories from one placeto another. The original filename or directory name is no longer accessible. The newfilename may be same in another directory and/or a different filename.

    http://en.wikipedia.org/wiki/Computer_filehttp://en.wikipedia.org/wiki/Directory_(file_systems)http://en.wikipedia.org/wiki/Computer_filehttp://en.wikipedia.org/wiki/Directory_(file_systems)
  • 8/7/2019 spsa exp 4

    20/25

    Syntax: $ mv file1 file2Options:

    (i)-i: interactively process, write a prompt to standard error before moving afile that would overwrite an existing file. If the response from the standard input

    begins with the character`y' or `Y', the move is attempted.

    (ii)-f: force overwriting the destination

    (iii)-v: verbose, shows filenames/directory names after they are moved.

    Example:

    rm

    Purpose: rm (short for remove) to remove objects such as files, directories, devicenodes, symbolic links, and so on from the filesystem. To be more precise, rm removesreferences to objects from the filesystem, where those objects might have hadmultiple references (for example, a file with two different names), and the objectsthemselves are discarded only when all references have been removed.Syntax: $ rm [-options] filename(s)

    Options:(i)-i: It is used for interactive deletion. If we are given the command ofdeletion , it will ask the user whether it want to delete the file or not.(ii)-r: This is used to delete the files recursively i.e. it is used to delete a nonempty directory not the files. If the file/directory doesnt have permission ofwrite, it wont be deleted.

    Example:

    http://en.wikipedia.org/wiki/Device_nodehttp://en.wikipedia.org/wiki/Device_nodehttp://en.wikipedia.org/wiki/Symbolic_linkhttp://en.wikipedia.org/wiki/Device_nodehttp://en.wikipedia.org/wiki/Device_nodehttp://en.wikipedia.org/wiki/Symbolic_link
  • 8/7/2019 spsa exp 4

    21/25

  • 8/7/2019 spsa exp 4

    22/25

    head

    Purpose: it will display first few lines of file. By default 10 lines will be printed.

    Syntax: $ head filename

    Options:(i)-n: It will display how many lines you want to be displayed of a file. If this

    number of files doesnt exist,then scrolling will occur. It will show only the existinglines.

    Example:

  • 8/7/2019 spsa exp 4

    23/25

    tail

    Purpose: output the last part of files. Print the last 10 lines of each FILE to standardoutput. With more than one FILE, precede each with a header giving the file name.With no FILE, or when FILE is -, read standard input.

    Syntax:

    $ tail filename(s)$ tail n filename(s)

    Example:

    14.Command: more

    Purpose: This command is frequently used to display larger files. It displays outputone screen at a time. If enter is pressed, next line would be displayed and if space baris pressed, next page would be pressed. We can specify more than one option at atime.Syntax: $ more [option(s)] filenameEg: $ more s u d or

    $ more s u d

    Options:

    (i)-num: It specifies the screen size how many lines the user want to access at

    a time.

  • 8/7/2019 spsa exp 4

    24/25

    (ii)-d: This option prompts the user with the message press space to continueand q to quit.

    (iii)-p: It does not scroll the page. If the user is on page2, it cant move topage1 and to move to page3, screen for page2 will be clear and page3 will be

    loaded.

    (iv)-s: This option squeezes multiple blank lines into one.

    (v)-u: This option suppresses the underlinings.

    (vi)+num:This command will show the lines of a file after the value given inum.

    Example:

  • 8/7/2019 spsa exp 4

    25/25

    15.Command: man

    Purpose: The man command is short for manual and provides in depth informationabout the requested command or allows users to search for commands related to aparticular keyword.Syntax: man topicExample: