Use of cp, rm, and mv commands and cp commands in Linux Command lines

Source: Internet
Author: User

Use of cp, rm, and mv commands and cp commands in Linux Command lines

The following content comes from laruence's private kitchen

Copy, delete, and move Linux Command lines: cp, rm, and mv

Cp (copy) replication

The cp command is used for many purposes. In addition to simple copying, you can also create a link file to compare the old and new files and update them,

And copy the entire directory.


Cp [-adfilprsu] source file target file


Destination File (destination)


-A: equivalent to-pdr. See the following document.

-D: if the source file is a link file, copy the link file property instead of the file itself.

-F: force means to overwrite existing files.

Rm (remove) Delete


Rm [-rfi] file or directory


-R: recursive operation

-F: force)

-I: The deletion prompt is displayed.

This rm-rf file/dir command is very dangerous unless it is very definite,

Otherwise, I option is recommended.

Note: this should be done when a file starts with-and is deleted.

# Rm-rf ---filename-

Add --

Or specify a file in a directory, such

# Rm-rf./-filename-

Mv (move) move a file or directory and rename it


Mv [-finu] source destination

Mv [-finu] source... directory


-F: if the target file exists, it will be overwritten.

-I: a prompt is displayed.

-N: if the target file exists, it is not overwritten.

-U: if the source file is newer than the target file, or the target file is lost, it is updated. Otherwise, it is not updated.

In the same directory, music videos can also be renamed.

# Mv abc CBA

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: 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.