Common Centos Operating commands

Source: Internet
Author: User
Tags printable characters uncompress
Common Centos commands 1. Directory commands ls & mdash; function description: displays the list of files and directories. & Mdash; command format: ls [parameter] [& lt; file or directory & gt; & hellip;] & mdash; common parameters:-: do not hide any .... common Centos Operation Commands 1. Directory operation command ls-function description: displays the list of files and directories. -Command format: ls [parameter] [ <文件或目录> …] -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-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 [parameter] [ <目录> ]-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-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-P cd command-function description: switch the directory. -Command Format: cd [parameter] [ <目录> ]-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] <目录> -Common parameter:-p: create a directory tree. if 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] <目录> -Common parameter:-p: delete the directory and 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] <文件> ... -Common parameters:-a: only change the access time. -M: only change the modification time. -T : The time in the [[CC] YY] MMDDhhmm [. ss] format is used instead of the current time. -R <参考文件或目录> : 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] <源> <目标> -Common parameters:-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] <源> <目标> -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] <文件> ... -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] <被链接的文件> <链接文件名> -Common parameters:-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] <目录> [ <目录> …] -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 [Parameters] <文件> ... -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. - <压缩率> : The compression ratio is between 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] <文件> ... -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. - <压缩等级> : 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] <目录> ... -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.
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.