Linux file Management command CP, MV, RM

Source: Internet
Author: User

Linux file Management

CP, MV, RM

Copy command: CP

CP [Option] ... [-T] SRC (source) DEST (Purpose)

(If the target does not exist, a new dest is created and the content in Src is populated into dest.)

If the target exists: If Dest is a file, the SRC content is overwritten in dest. We recommend that you use the-i option for the CP command.

If Dest is a directory, create a new file with the same name as the original file under Dest and populate the contents of SRC with dest)

Example: Cp/etc/fstab/tmp/out.tmp (out.tmp as file)

Cp/etc/fstab/tmp/out (out for directory)

CP [Option] ... SRC (original file) ... (multiple files available) Directory (new directory) (which directory is copied to)

If SRC is a multiple file, directory must be present and directory, and other cases are wrong.


CP SRC DEST

SRC is the directory:

Use option at this time:-R (Recursive recursion)

Create the specified directory if dest does not exist, copy all directories in src directory to dest

If dest exists:

If the dest is a file, the error

If Dest is a directory, copy to this directory

Common options:

-I: Interactive

-R: Recursively replicate directories and all content inside them

-A: Archive, equivalent to-DR--preserv=all (that is, preserve the attributes of the source file or directory, including the owner, the owning group, the permissions and the time)

-D:--no-dereference--preserv=links (if the original file is a link, keep the original link format)

--preserv=[attr_list] (reserved property)

Mode: Permissions

Ownership: Belong to the main group

Timestamp: Time stamp

Links: Link

XATTR: Special Attributes

Context: Contexts

All: All

-P =--preserve=mode, ownership, timestamp

-V Show More information

-T can put the target in front when copying

-F--force forced replication (dangerous)

such as: Cp/etc/apache2/tmp/apache2 (/etc/apache2,/tmp/apache2 as directory,)

Cp-p/var/tmp/a.txt./temp/(Reserved property)


Move File command: MV

MV [Option] ... [_t] SOURCE DEST to move the original file to the target file, which is renamed

MV {Option] ... SOURCE ... Directory to move source files to the destination file directory

MV [Option] ...-t directory SOURCE takes directory as a mobile target


Option

-I interactive with prompt operation

-F Mandatory


such as: MV Test.log Test1.txt (renamed to Test.txt)

MV Test1.txt temp/(move to temp directory)


Delete command: RM

RM [OPTION] ... FILE ...

Common options:

-I: Interactive

-F: Force delete

-R: Recursive


Rm-f A.log (forcibly delete files)

Rm-r tmp/(delete tmp directory and its subdirectories and files)


Linux file Management command 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.