Linux Common commands: CP,MV,RM

Source: Internet
Author: User

CP (copy)

The CP command can copy files or directories, and can also create linked files.

[[email protected] ~]# CP [-ADFILPRSU] source file (source) destination file (destination) [[email protected] ~]# CP [Options] Source1 source2 s Ource3. Directory-r,-R,--recursive copy directories recursively-p same As--preserve=mode,ownership,timestam Ps-a,--archive same as-dr--preserve=all [can keep linked files], generally only root execution

To copy a file :

# CP a B C D # What does that mean? Source:a b C, destination:d, copy a b c to directory D


# cp/etc/a.txt/tmp/b

If B is a directory: Copy the a.txt to the B directory

If B is a file:

If B does not exist, copy the a.txt and rename it to B

If b exists, indicates whether to overwrite



To copy a directory :

# cp/etc/tmp

Cp:omitting directory '/etc '

# cp-r/etc/tmp # Copy directory needs to use the-r recursion option


To copy a hidden file :

With CP */tmp How can I copy the hidden files together in this type of operation?

We can only copy all non-hidden files by playing this command above. The reason for this is:(wildcard characters cannot match the file name with "." Files that begin with)


# cp-a. /tmp # Right

# CP. */tmp # just copy hidden files



MV (move)

The MV command is typically used to move files and rename them.


# mv/etc/somedir/tmp/somefile # error, cannot use directory to overwrite file

# mv/etc/somedir/tmp/somedir # Yes



RM (remove)

The RM command is used to delete files and directories. With it the basic will not use rmdir this again.

RM-RF Command Usage rules:

1, in the production environment, do not always log on as the root user

2, operation, than is slow and careful, not fast, press ENTER before you must repeatedly check

3, the key business operations, it is best to find a colleague in the side to see, testify

4. Turn on the analog terminal software logging function



This article is from the "Share Your Knowledge" blog, so be sure to keep this source http://skypegnu1.blog.51cto.com/8991766/1934756

Linux Common commands: CP,MV,RM

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.