Common centos operating commands

Source: Internet
Author: User
Tags gz file printable characters uncompress
I. Directory Operation Command LS command-Function Description: displays the file and directory list. -Command Format: ls [parameter] [<file or directory>…] -Common parameters:-A: Do not hide any entries starting with the "." character. -B: Non-printable characters are displayed in octal format. -R: recursively lists all subdirectories. -D: When a directory is encountered, the directory itself rather than the files in the directory will be listed without following the symbolic link. -F: add the file type indicator (*,/, =, @, |, one of them) after the entry ). -L: Used to list information in a long format. -L: when the file information of the symbolic link is displayed, the object indicated by the symbolic link is displayed, not the information of the symbolic link itself. -X: List projects row by row instead of column. -1: only one file is listed in each row. -R: in reverse order. -S: sort by file size. -X: sort by extension. -C: sort by ctime. -T: sort by the last modification time (mtime. -U: sorted by the last access time (atime. -Example: ls LS-a ls-F ls-l LS-r LS-Sl LS-rl LS-Cl LS-Tl LS-ul ls some/DIR/file ls some/DIR/ls -d Some/DIR/Tree Command-function description: displays the file and directory tree. -Command Format: Tree [parameters] [<directory>]-common parameters:-A: Do not hide any entries starting with the "." character. -D: displays only directories and does not show files. -F: the path is displayed for each file. -F: add the file type indicator (*,/, =, @, |, one of them) after the entry ). -R: in reverse order. -T: sort by the last modification time (mtime. -L n: only the n-layer directory is displayed (N is a number ). -Dirsfirst: the directory is displayed after the previous file. -Example: TREE tree-D tree-F tree-L 3 tree/Some/DIR/PWD command-Function Description: displays the current working directory. -Command Format: Pwd [parameter]-common parameter:-P: If the directory is a symbolic link, the physical path rather than the symbolic link is displayed. -Example: Pwd PWD-P cd command-Function Description: Switch the directory. -Command Format: CD [parameter] [<directory>]-common parameter:-P: If the directory is a symbolic link, the physical path rather than the symbolic link is displayed. -Example: CD/Some/DIR/CD-P examples CD ~ CD ../.. CD-mkdir command-Function Description: create a directory. -Command Format: mkdir [parameter] <directory>-common parameter:-P: create directory tree. When required, create an upper-level directory. If the directory already exists, it is not considered as an error. -Example: mkdir somedir/and mkdir-p Some/path/DIR/rmdir command-Function Description: delete an empty directory. -Command Format: rmdir [parameter] <directory>-common parameter:-P: Delete the directory, and then try to delete all the upper-level directories in the specified path. For example, rmdir-p a/B/C is equivalent to rmdir A/B/c a/B. -Example: rmdir somedir/rmdir-p Some/path/DIR/2. File Operation Command touch-Function Description: generate a new empty file or change the timestamp of an existing file. -Command Format: Touch [parameter] <File>... -Common parameters:-A: only change the access time. -M: only change the modification time. -T <stamp>: The time in the format of [[CC] YY] mmddhhmm [. SS] instead of the current time. -R <reference file or directory>: use the time attribute of the specified file instead of the current time. -Example: Touch newfile touch file touch-a file touch-M file touch-T 200701311200 file-GNU/Linux Files have three types of timestamps: mtime: last modification time (LS-lt) ctime: State Change Time (LS-LC) atime: Last access time (LS-Lu) Note: 1. ctime is not the file creation time. 2. Overwriting a file changes all three types of time: mtime, ctime, and atime. 3. Changing the file access permission or the owner will change the file ctime and atime. 4. Reading a file changes the atime of the file. CP command-Function Description: copy a file or directory. -Command Format: CP [parameter] <source> <target>-common parameter:-A: equivalent to-DPR. -D: When copying the source file of the symbolic link, the target file will also create a symbolic link and point to the original file linked to the source file. -F: Forced replication, regardless of whether the target exists. -I: Interactive replication, which must be confirmed before overwriting the file. -P: retains the attributes of a file during file copy, including the owner, group, permission, and timestamp. -R,-R: recursively copy all the items in the directory and directory. -L: Create a hard link to the source file instead of copying the file. You can also use the ln command. -S: Create a symbolic link to the source file instead of copying the file. You can also run the Ln-s command. -U: only when the source file's modification time (ctime) is later than the target file's update time or the target does not exist. -Example: CP file1 file2 CP some/DIR/file1 someother/DIR/CP some/DIR/file1 someother/DIR/file2 CP some/DIR/file. CP some/DIR/Files someother/DIR/CP some/DIR/file1 some/DIR/file2 some/DIR/file3 someother/DIR/CP-r some/DIR/someother/Dir /CP-Au some/DIR/someother/DIR/mv command-function description: rename a file or directory, file or directory. -Command Format: MV [parameter] <source> <target>-common parameter:-F: force move, regardless of whether the target exists. -I: Interactive movement. confirmation is required before overwriting the file. -U: only when the source file's modification time (ctime) is later than the target file's update time or the target does not exist. -Example: MV/Some/DIR/file1/someother/DIR/MV/Some/DIR/file1/someother/DIR/file2 mV/Some/DIR/files/someother/DIR/mv file newname_file MV dir newname_dir RM command-function description: delete a file or directory. -Command Format: Rm [parameter] <File>... -Common parameter:-F: indicates that a nonexistent file is skipped and no information is displayed. -I: You must confirm before performing any delete operation. -R,-R: recursively deletes all directory layers under this directory. -Example: Rm/Some/DIR/file1 Rm-I/Some/DIR/file1 Rm-F/Some/DIR/file1 Rm-RF/Some/DIR/Note 1. by default, RM does not delete the directory. Use the-recursive (-R or-R) option to delete each given directory and all its contents. 2. to delete a file with the first character "-" (for example, "-foo"), use one of the following methods: Rm--Foo RM. /-F ln command-Function Description: create a link file. -Command Format: ln [parameter] <linked File> <link file name>-common parameter:-S: Create a symbolic link instead of a hard link. -F: creates a link forcibly, whether or not it exists. -I: Ask the user before overwriting the original file. -Example: ln somefile hardlinkfile ln-s somefile softlinkfile ln-s somedir softlinkfile symlinks command-function description: Check the symbolic link in the directory and display the symbolic link type. -Command Format: symlinks [parameter] <directory> [<directory>…] -Link Type: Absolute: Use the symbolic link of the absolute path. Dangling: a symbolic link that does not exist in the original file. Lengthy: the path of the symbolic link contains the redundant "../". Messy: the path of the symbolic link contains redundant "/". Other_fs: the original file is located in another file system. Relative: Use the symbolic link of the relative path. -Common parameter:-C: converts a symbolic link of the absolute/messy type to the relative type. -D: Delete the dangling symbolic link. -R: Check the symbolic links in all subdirectories of the directory. -S: shorten the symbolic link of the lengthy type. -V: displays symbolic links of all types. -Example: symlinks-v-R. symlinks-V/usr/bin symlinks-C somedir symlinks-s-d somedir 3. File packaging and compression command gzip command-Function Description :. GZ File compression and decompression program. -Command Format: gzip [parameter] <File>... -Common parameters:-A: Use the ASCII text mode. -C: output the compressed file to the standard output device without modifying the original file. -D: uncompress the compressed file. -F: forcibly compress the file, regardless of whether the file name or hard link exists and whether the file is a symbolic link. -L: lists information about compressed files. -L: displays the version and copyright information. -N: the original file name and timestamp are not saved when the file is compressed. -N: the original file name and timestamp are saved when the file is compressed. This is the default value. -Q: no warning information is displayed. -R: recursive processing. All files and subdirectories in the specified directory are processed together. -T: test whether the compressed file is correct. -V: displays the command execution process. -V: displays gzip version information. -<Compression rate>: the compression rate ranges from 1 ~ The value of 9. The default value is "6". The larger the value, the higher the compression ratio. -Best: the effect of this parameter is the same as that of the specified "-9" parameter. -Fast: the effect of this parameter is the same as that of the specified "-1" parameter. -Example: gzip filename gzip-V file1 file2 gzip-C file1 file2> foo.gz gzip-L *. GZ gzip-D filename.gz Bzip2 command-Function Description :. bz2 File compression and decompression program. -Command Format: Bzip2 [parameter] <File>... -Common parameter:-C: outputs the compressed file to the standard output device without modifying the original file. -D: uncompress the compressed file. -F: forcibly compress the file. -K: Retain the original file. By default, the original file will be deleted after compression or decompression. -S: reduces the memory usage during program execution, but increases the execution time. -T: test whether the compressed file is correct. -V: displays the command execution process. -V: displays Bzip2 version information. -<Compression level>: the compression level is 1 ~ Specifies the block size during compression. -Repetitive-best: this parameter can be used to improve the compression effect if duplicate data appears in the file. -Repetitive-fast: this parameter can be used to speed up execution if duplicate data appears in the file. -Example: Bzip2 filename Bzip2-VK file1 file2 Bzip2-C file1 file2> foo.bz2 Bzip2-T *. bz2 Bzip2-D filename.bz2-Note: Bzip2 compresses files in blocks, and each block is considered as an independent unit. Therefore, when a block is damaged, you can use the bzip2recover command to try to separate the blocks in the file so as to shrink the normal blocks. It is usually only applicable when the compressed file is large. Tar command-Function Description: Package and package. -Command Format: Tar [parameter] <directory>... -Common parameter:-F name: Specifies the archive file name or device name using name. -V: lists detailed information about processing. -C: used to create a new archive file. -X: Restore the backup file from the archive file. -T: Used to list the file names in an archive file. -Z: Use GNU Gzip to compress or decompress the file. -Z: compress the file or decompress it. -J: Use Bzip2 to compress or decompress the file. -Example: tar-CVF myball.tar somedirname tar-TF myball.tar-xvf myball.tar-zcvf myball.tar.gz somedirname tar-ztf myball.tar.gz tar-zxvf myball.tar.gz tar-jcvf myball.tar.bz2 somedirname tar-JTF myball.tar.bz2 tar-jxvf extends (CD/source/directory & tar CPF -.) | (CD/DEST/directory & tar xvfp-)-tip: Similarities and Differences between compressed files and archive files-same: is a collection of files and directories. -Different: the disk space occupied by archive files is the sum of all files and directories. Generally, the disk space occupied by the compressed files is less than the total space of all the files and directories in the compressed files. Archive files are not compressed files, but compressed files can be archive files. Data source: http://www.2cto.com/ OS /201304/204902.html
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.