Copy, move, and delete files under Linux

Source: Internet
Author: User

The copy, move, and delete commands for files under Linux are: CP,MV,RM
I. File COPY command CP
Command format: CP [-ADFILPRSU] source file (source) destination file (destination)
CP [option] source1 source2 source3 ... directory
Parameter description:
-A: Refers to the meaning of archive, but also refers to copying all the directories
-D: If the source file is a connection file, the connection file property is copied instead of the file itself
-F: Mandatory (force), if there are duplicates or other questions, do not ask the user, and force replication
-I: If the target file (destination) already exists, the overwrite will ask if the action is true
-L: Create a hard link connection file instead of copying the file itself
-P: Copy with the properties of the file instead of using the default properties
-R: Recursive replication for directory replication operations
-S: Copy into a symbolic connection file (symbolic link), which is the "shortcut" file
-U: If the target file is older than the source file, update the target file
If you copy file1 from the/test1 directory to the/TEST3 directory and change the file name to File2, you can enter the following command:
Cp/test1/file1/test3/file2 (the folder is copied)

If you want to copy all files under a folder: cp-rf/test1/file1/*/test3/file2/


Second, the file Movement command MV
Command format: MV [-FIV] source destination
Parameter description:
-f:force, forcing direct movement without asking
-I: If the target file (destination) already exists, you will be asked to overwrite
-U: Update if the target file already exists and the source file is newer
If you copy file1 from the/test1 directory to the/TEST3 directory and change the file name to File2, you can enter the following command:
Mv/test1/file1/test3/file2


Third, the file Delete command rm
Command format: RM [fir] File or directory
Parameter description:
-F: Force delete
-I: Interactive mode, asking the user whether to operate before deleting
-R: Recursive delete, commonly used in directory deletion
If you delete the File1 file under the/test directory, you can enter the following command:
Rm-i/test/file1

Copy, move, and delete files under Linux

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.