Linux Learning - commonly used commands

1. Check the Help: man 

   Exit Help Contents: q

2. Change directories: cd

  cd directory

  cd directory / directory

  CD .. (go back one level)

  CD / (root)

  ~ cd (home)

3. Create a directory and delete directories

  mkdir create

    mkdir directory name

    mkdir -p a/b/c

  rmdir Delete

    rmdir directory name (only delete an empty directory)

4 shows a directory listing the file (you can later use ll)

  ls show can see the files (and directories) name

  ls -a show the names of all the files (in front of the file there. "" represents the hidden file)

  ls -l show details of the file (shorthand way: ll)

  ls -h  -friendly display

5. Browse file

  cat filename displays the contents of all files

  more Pagination

    Space: next page

    Enter: The next line

  less Pagination

    You can view the page by PgUp PgDn

  tail view a file's contents back

    tail - After displaying a few lines of the file name

    tail -f filename

      Dynamic view for example: tail -f catalina.xxx.log (by the end of ctrl + c to scroll)

6. Operation files

  Create a file

    touch the file name   to create a blank file

  Copy files

    cp file directory / file names     such as: cp 1.txt 2.txt cp 1.txt 1 / 1.txt

  Move files (rename)

    mv file directory / file name

    mv file name new file name

  Delete Files

    rm filename with asking deleted

    rm -f file name without asking delete

    rm -r directory with a recursive delete inquiry

    rm -rf directory without asking recursive delete (use caution)

  Pack or unpack a file or directory

    Common combination:

        -cvf package a file or directory

        -zcvf packaged and compress a file or directory compression formats: gzip

        tar -xvf unzip or open a file

     Format: tar parameter file name you want to pack / unpack files directory

      For example: all files in the current directory packaged into test1.tar      tar -cvf test1.tar./*

         All files in the current directory packaged and compressed into test2.tar.gz      tar -zcvf test2.tar.gz ./*

         The test1.tar extract to the current directory     tar -xvf test1.tar

         B test1.tar extract to the directory     tar -xvf test1.tar -C b  

Guess you like

Origin www.cnblogs.com/Duxue/p/11422071.html