Linux file system, redirection and summary of common commands

Source: Internet
Author: User

First, common commands

Touch command: Touch [OPTION] ... FILE ...-a:atime-m:mtime-c:ctimeaccess, modify, change three timestamp differences: Access time, Atime, read its content through cat, more, etc. modify: Modify Time , Mtime, change the contents of the file changes: Change the time, CTime, change the file metadata, that is, modify the permissions, belong to the group, belong to the master, etc.

Use the stat command to view a file with three timestamps as follows:

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/85/21/wKioL1eawX3x5McLAAAyS42xzlg927.png "title="%j@q[] _61~v72m) 1t2pmatl.png "alt=" Wkiol1eawx3x5mclaaays42xzlg927.png "/>

CP command: CP [OPTION] ... [-T] SOURCE DEST CP [OPTION] ... SOURCE ... Directory CP [OPTION] ...-t DIRECTORY SOURCE ...    Common options:-r: Recursively copy all contents of directory and Content-A: archive-D: Indicates that the source file pointed to by the symbolic link is not tracked, directly copy the link file-P: Keep the property information of the original file-F: Force override-V: Display process-r: Recursively copy directory and all internal content -I: Interactive-preserv=[...] mode: Permissions ownership: Genus Group Timestramp: timestamp

1. If the destination file does not exist, create a target file to copy the contents of the source file to the new target file.

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M02/85/21/wKioL1eaw_qSTp4XAAAreWYpyrY539.png "title=" fu7v1m ~l~e37o~lvctaz%yy.png "alt=" Wkiol1eaw_qstp4xaaarewypyry539.png "/>

2. If the target file exists, then prompt to overwrite the contents of the target file

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/85/21/wKioL1eaxFCh4KRIAAAb72glXUg021.png "title=" YC6) @ 2h45e0wcwcf%shoc}i.png "alt=" Wkiol1eaxfch4kriaaab72glxug021.png "/>

The following indicates that the user is not prompted to overwrite: \CP chen.txt/testdir/test /USR/BIN/CP chen.txt/testdir/test                             

1, using the alias command, the daily/etc/directory of all files, backup to/testdir/under the new directory, and require the new directory format is BACKUPYY-MM-DD, the backup process is visible

Alias cp= ' cp–av/etc/testdir/backup ' date +%f '

2, first create the/testdir/rootdir directory, and then copy the/root all the next file into the directory, and ask to retain the original permissions

cp/root/-R--preserv=mode/testdir/rootdir or: cp-av/etc/testdir/backup$ (date)

MV Command: Common options:-I: Interactive-f: Force RM Command: Common options:-I: Interactive-F: Forced-r: Recursive


Tree command:-D: Show only Directories-L level: Specifies the number of levels displayed tree–l 2/etc/-P pattern: Displays only the path that is matched by the specified pattern-p: Show permissions

650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/85/22/wKiom1eayPKiRHCRAABM7ETamkE558.png "title=" _ (7k%r ] (q_wajyobj_%muas.png "alt=" Wkiom1eaypkirhcraabm7etamke558.png "/>650) this.width=650;" src= "http:// S2.51cto.com/wyfs02/m00/85/22/wkiom1eayzgajngzaaas-yyk7po987.png "title=" LD) {8) O] (0@85}q[7_384]c.png "alt=" Wkiom1eayzgajngzaaas-yyk7po987.png "/>

mkdir Create Directory-P: exists in no error, and can automatically create the required directories;-V: Show details-M MODE: Specify the permissions directly when creating the directory;


RmDir Delete Empty directory-P: Recursive Delete parent Empty directory-V: Show details rm-r recursively delete directory tree


(1) How to create/testdir/dir1/x,/testdir/dir1/y,/testdir/dir1/x/a,/testdir/dir1/x/b,/testdir/dir1/y/a,/testdir/dir1/y/b


MKDIRI–P/TESTDIR/DIR1/{X/{A,B},Y/{A,B}}


(2) How to create/testdir/dir2/x,/testdir/dir2/y,/testdir/dir2/x/a,/testdir/dir2/x/b


Mkdir-pv/testdir/dir2/{x/{a,b},y}


(3) How to create/TESTDIR/DIR3,/TESTDIR/DIR4,/TESTDIR/DIR5,/TESTDIR/DIR5/DIR6,/TESTDIR/DIR5/DIR7


mkdir–p/testdir/dir{3,4,5/dir{6,7}}

MKDIR–P/TESTDIR/{DIR3,DIR4,DIR5/{DIR6,DIR7}}

Files can contain multiple types of data-checking file types, and then determine the appropriate open command or application using file [Options]<filename>    Option:-B The file name is not displayed when the file identification results are listed. -C verbose display of the instruction execution process, easy to debug or parse the program execution-F list File name file type-F with the specified delimiter symbol to replace the output file name after the default ":" Delimiter-I output MIME type string-l view the corresponding soft link file type- Z try to interpret the contents of the compressed file--help display command online Help

Second, redirect

Standard input and output: Program: Instruction + Data read-in data: Input output data: Outputs open files have a Fd:file descriptor (file descriptor) Linux gives the program three I/O devices standard input (STDIN)-0 Default accept input standard output from keyboard (STDOUT)-1 Default output to terminal window standard error (STDERR)-2 default output to terminal window I/O redirection: Changing the default location supported operation symbols include: > redirect output to file 2> redirect error output to file &> Redirect all output to File > file contents will be overwritten # Set-c: Prevents content from overwriting existing files, but can append mandatory overrides: >| # set +c: Allow overwrite >> original content, append content > File content will be overwritten # Set-c: Prevents overwriting of existing files, but can append mandatory overrides: >| # set +c: Allow overlay >> original content, append content


This article is from "Wake up your not alarm clock but dream" blog, please be sure to keep this source http://purify.blog.51cto.com/10572011/1831626

Linux file system, redirection and summary of common commands

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.