Os Report Linux 2

download Os Report Linux 2

of 16

Transcript of Os Report Linux 2

  • 7/27/2019 Os Report Linux 2

    1/16

    File Commands in Linu

  • 7/27/2019 Os Report Linux 2

    2/16

    The cat command (concatenate) displays the contents ofthe specified file. The cat command can be used tovertically concatenate the contents of more than onefile.

    Example

    [Steve@localhost Steve] $ cat data1

    A sample file

    [Steve@localhost Steve] $ cat data1 data2

    A sample fileAnother sample file

    The command assumes that the file data1 is in the current directory .Complete path names can also

    to display more than one file, as shown.(You can create a file by using the command cat > filename . After ycontents of the file, you need to press Ctrl+d to end the creation of the file. )

  • 7/27/2019 Os Report Linux 2

    3/16

    The cp (copy) command duplicates the contents of thesourceSyntaxcp [options]

    Example

    [Steve@localhost Steve] $ cp data1 data2

    in the above example , the contents of data1 are copied to a new file data2. If data

    Its contents will be overwritten by the contents of data1. Complete path names can bethe cp command to copy files across directories. You can also copy a directory recursive

    command with r option.

    [Steve@localhost Steve] $ cp r temp tempo

    The above command copies the temp directory and all its files and sub-directories to tdirectory ,tempo, exists, all the contents are added to that directory , otherwise tempcurrent working directory.

  • 7/27/2019 Os Report Linux 2

    4/16

    Options with the cp command

    Option Function

    -i Prompts before over

    -l Links a file instead of c

    -s Creates a symbolic

    -v Verbose-explains what is bein

  • 7/27/2019 Os Report Linux 2

    5/16

    The rm (remove) command is used to delete files ordirectories.Syntaxrm [options] file/s

    Example

    [Steve@localhost Steve] $ rm data1 data2

    The above command will remove the files data1 and data2 from your current directory.deleted is not located in the current directory, the complete path name has to be given

    [Steve@localhost Steve] $ rm /home/Steve/data1

    The r option is used with the rm command to remove a directory along with its sub-dir

    [Steve@localhost Steve] $ rm r tempo

    The above command removes the tempo directory along with all its sub-directories

  • 7/27/2019 Os Report Linux 2

    6/16

    Options of the rm command

    Option Function

    -i Prompts before remo

    -f Removes a file by force .if the file

    the command does not flag

    -r or -R Deletes recursively, that is, delealong with its sub-dire

    -v Verbose-explains what is b

  • 7/27/2019 Os Report Linux 2

    7/16

    The mv (move) command is used to move a file or directory from oanother or to change its name .Syntaxmv [option] source destination

    Example

    [Steve@localhost Steve] $ mv comm communication

    In the above example, the comm directory is renamed to communication.

    [Steve@localhost Steve] $ mv data3 /home/Steve/programs/

    In the above example, the file data3 is moved from the current directory to the /home/Stev

    directory.[Steve@localhost Steve] $ communication temp

    In the above example, the directory temp exists in the current directorthe communication directory is moved from the current directory

    To the temp directory.

  • 7/27/2019 Os Report Linux 2

    8/16

    Options of the mv command

    Option Function

    -f If the file exists at destination, itprompting

    -i Interactive, prompts before oAt the destination locat

    -v Verbose-explains what is being d

  • 7/27/2019 Os Report Linux 2

    9/16

    Displays the contents page-wise

    The cat command is used to display the contents of a file on the screen . Hofile being displayed is large, then the entire contents will scroll up the screefile one screen-full at a time, you can use the more or less command. The mis used to display data one screen-full at a time. While viewing a file using command , once you have scrolled down, you cannot move up.

    Syntax

    more [options]

    Example

    [Steve@lsrv01 HOWTO] $ more XWindow-User-HOWTO

    The above command will display a page-wise listing of the contents of the fileUser-HOWTO.

  • 7/27/2019 Os Report Linux 2

    10/16

    The less command is similar to the more command except that you canalso while viewing the contents of a file. The less command is also fastecommand.

    Syntax

    less [options]

    Example

    [Steve@lsrv01HOWTO] $ less XWindow-User-HOWTO

    The above command will display a page-wise listing of the contents of theUser-HOWTO.

    To move up and down the screen ,you can use the arrow keys. You can alsonumber to move down the screen by that number of lines. To quit the disptype q.

  • 7/27/2019 Os Report Linux 2

    11/16

    Wildcard characters

    Character Purpose

    * Matches none or one charactcharacters

    ? Matches exactly one c

    [] Matches exactly one of a spcharacters

  • 7/27/2019 Os Report Linux 2

    12/16

    The *Wildcard

    The *wildcard is interpreted as a string of none, one, or more charac

    Example[Steve@localhost Steve] $ ls c*

    The above command displays all files whose names start with c. The also be repeated in the command line.

    Example

    [Steve@localhost Steve] $ ls chap*.*

    The above command displays all the files starting with chap and containsequence of characters(or no characters), followed by a dot ,and then fsequence of characters (or no character).

    Note that . Is not a special character for *

  • 7/27/2019 Os Report Linux 2

    13/16

    The ?Wildcard

    The ? Wildcard matches exactly one occurrence

    character.

    Example

    [Steve@localhost Steve] $ ls *.?

    The above command displays all files having any character(s) before a dot , followed by a singlecharacter after the dot.

  • 7/27/2019 Os Report Linux 2

    14/16

    The []Wildcard

    The []wildcard can be used to restrict the characters t

    matched.Example

    [Steve@localhost Steve] $ cat a[123]

    This displays the contents of the files with two charactestarting with a with the next character as 1,2, or 3, for a1,a2, and a3

  • 7/27/2019 Os Report Linux 2

    15/16

    Linux help manual

    Online Help is an integral part of every software . It provides u

    facility to seek help on various commands and the options avaicommands. The online Help pages are referred to as the manua(man) in linux and provide online help to a user about the variofor any command in linux. They are part of the Linux DocumenProject (LDP).

    Syntax

    Man enter

    Example

    $man passwd enter

    To obtain various options of the passwd command

  • 7/27/2019 Os Report Linux 2

    16/16

    Prepared by: Ocampo, Jameson P.

    Courtesy of papajuls group