Linux Common commands-file management (ii)

Source: Internet
Author: User

One,CP

1, main function : copy files or directories

2, grammar

CP [ parameters ] [ source file or directory ] [ destination file or directory ] [destination directory ]

3, common parameters

-B Delete, overwrite the backup before the target file, the backup file will add a device string at the end of the word

-F forcibly copy a file or directory regardless of whether the destination file or directory already exists

-I ask the user before overwriting existing files

-P Keep the path to the source file or directory

-R recursive processing, processing files in the specified directory with subdirectories

-R Recursive processing, processing all files and subdirectories under the specified directory

-help Display Help information

4, Example

1, copy the/etc/dhcpd.comf to /TMP/WX using the CP command

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6E/BE/wKioL1WFUNKhE4XxAAE6yaFKNqA315.jpg "title=" Cp1.jpg "alt=" Wkiol1wfunkhe4xxaae6yafknqa315.jpg "/>


2, use the mkdir command to create the/tmp/test directory, recursively copy files with Cp–r, and copy subdirectories or files under the directory.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6E/C1/wKiom1WFT0qDoYwiAAgPM4XsDeY097.jpg "title=" Cp2.jpg "alt=" Wkiom1wft0qdoywiaagpm4xsdey097.jpg "/>


3,mkdir Create xzy directory under/tmp , use cp-l to integrate hard connection file, /var/log/messages Log files are hard-wired to /tmp/xzy/messages, Restart the DHCP service and view the log records compared to two files and found two files for data synchronization .

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/C1/wKiom1WFT4OQqBbhAAF_YHgELME775.jpg "title=" Cp4.jpg "alt=" wkiom1wft4oqqbbhaaf_yhgelme775.jpg "/>650" this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/ 6e/c1/wkiom1wfuabhtmy4aabk4zhjlyc593.jpg "title=" cp5.jpg "alt=" Wkiom1wfuabhtmy4aabk4zhjlyc593.jpg "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6E/C1/wKiom1WFUHay_XvmAAcK6B2_oxM822.jpg "title=" Cp6.jpg "alt=" wkiom1wfuhay_xvmaack6b2_oxm822.jpg "/>650" this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/ 6e/be/wkiol1wfukojzocdaabhso2og6o974.jpg "title=" cp7.jpg "alt=" Wkiol1wfukojzocdaabhso2og6o974.jpg "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/C1/wKiom1WFUJ2DQOqQAAdUz6Z3HGc823.jpg "title=" Cp8.jpg "alt=" Wkiom1wfuj2dqoqqaaduz6z3hgc823.jpg "/>



Two,MV

1 Main Features: Move or rename an existing file or directory

2, grammar

MV [ parameter ] [ source file or directory ] [ destination file or directory ]

3, common parameters

-B If you need to overwrite the file, make a backup before overwriting

-F Overwrite the existing file or directory directly if the destination file or directory is duplicated with an existing file or directory

-I ask the user before overwriting

-U does not overwrite the destination file if the destination file already exists and its file date is newer than the source file when you move or change the file name

-help Display Help information

4, Example

1 using the MV command to move the Dhcpd.log file to /tmp

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/6E/C2/wKiom1WFUNjAGaVkAAYzspBvHTY210.jpg "title=" Mv1.jpg "alt=" Wkiom1wfunjagavkaayzspbvhty210.jpg "/>


2. Use the MV command to rename the log file to log2

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6E/BE/wKioL1WFUs_BqPg5AAMb40akQZg375.jpg "title=" Mv2.jpg "alt=" Wkiol1wfus_bqpg5aamb40akqzg375.jpg "/>



three,pwd

1, main function: Show working directory

2, Syntax:

PWD [-help] [-version]

3, Common parameters

-help Online Help

-version displaying version information

4, Example

1 Viewing the current working directory using the PWD command

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6E/C2/wKiom1WFUT7wLTBZAAF3ECMcKvU023.jpg "title=" Pwd.jpg "alt=" Wkiom1wfut7wltbzaaf3ecmckvu023.jpg "/>




Four,RM

1, main function: Delete files or directories

2, Syntax:

RM [ parameters ] [ file or directory ]

3, common parameters

-D Delete the hard connection data of the deleted directory directly to 0, delete the directory

-F force removal of files or directories

-I ask users before deleting existing files or directories

-help Online Help

4. Example

1, using rm without parameters to delete the file, will ask the user whether to delete the file because the RM called the alias "rm-i", and when the command is executed, the path to write out the command will not ask the user. you can see its alias and the location of the command file using the which directory.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/C2/wKiom1WFUWfzGsqGAADea1I8o_o887.jpg "title=" rm.jpg "alt=" Wkiom1wfuwfzgsqgaadea1i8o_o887.jpg "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/BE/wKioL1WFU0ugeUzvAACNPF_5SP8828.jpg "title=" Rm2.jpg "alt=" Wkiol1wfu0ugeuzvaacnpf_5sp8828.jpg "/>



2, recursive deletion using the Rm–r command, which deletes subdirectories or files under the directory, but also asks the user whether to delete the file or directory. Use the rm–rf command to merge forcibly delete files or directories, there is no warning , This command is very dangerous to use with caution!

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6E/C2/wKiom1WFUcnxsBRyAAFDOWQ8YZc082.jpg "title=" Rm3.jpg "alt=" Wkiom1wfucnxsbryaafdowq8yzc082.jpg "/>




Five,rmdir

1, main function: Delete empty directory

2 Syntax

rmdir [ parameters ] [ Table of Contents ]

3, common parameters

-P Deletes the specified directory if the upper-level directory of the directory has become an empty directory .

-help Online Help

4, Example

1, create an empty directory, and then use the Rrmdir command to delete, but delete a directory with files in the directory can not be deleted

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6E/BE/wKioL1WFU96y7K4iAAFExYXRdo4509.jpg "title=" Rmdir.jpg "alt=" Wkiol1wfu96y7k4iaafexyxrdo4509.jpg "/>

This article is from the "ZJC" blog, make sure to keep this source http://zjclinux.blog.51cto.com/9796061/1663890

Linux Common commands-file management (ii)

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.