Instructions for copy, delete, and move command usage for linux files

Source: Internet
Author: User
Tags tmp folder

CP Replication Command

The CP command copies files from one location to another. If the destination file exists, the file will be overwritten; If the destination directory exists, the file is copied to the directory (the directory is not replicated).


Grammar is

CP [command Switch] ... SOURCE DEST


CP [Options]...–target-directory=directory SOURCE ...

Command switch:

-a equals-dpr.
-b like –backup, but not answered. Subject to parameters.
-p equals –preserve=m Ode,ownership,timestamps (retention mode, owner and timestamp information).
preserves the specified attributes (default properties: Mode, owner, timestamp) and security configuration, add additional attributes if possible: connection, all.
does not retain the specified property.


C Copy two files:

CP file1 FILE2 the CP command copies the contents of the file file1.php to the file file2.php.

Backup copies of files:

Cp-b file1.php file2.php Create a file file1.php with the symbol ' ~ ' backup file file2.php~.

To copy folders and subfolders:

The CP command above the CP-R scripts scripts1 copies folders and subfolders from scripts to Scripts1.

MV Move Command

MV command is the abbreviation for move. Use it to move/rename files from one directory to one directory. MV command is different from the CP command, the MV command is complete from the source to move the file and move the file to the specified directory, where the CP command just copy the contents of the file from one file to another file.


Grammar is

MV [-F] [-i] original name new name

Command switch:

-F Do not prompt before overwriting (equivalent to equivalent –reply=yes). Mv-f will move the file (multiple files) without prompting, even if it will overwrite the existing target file.
-I. Make a note before making a copy of another file


To rename/move a file:

MV File1.txt File2.txt

This command renames the File1.txt file with the name File2.txt.

To move a directory

Move a directory

MV Hscripts TMP

In the above command, if the TMP directory already exists, the MV command moves all files, directories, and subdirectories in the Hscripts folder/directory to the TMP directory. If there is no TMP directory, it renames the Hscripts directory as the TMP directory.

Move multiple files/More ask price to another directory

MV File1.txt Tmp/file2.txt Newdir

This command moves the file1.txt file of the current directory and the File2.txt file of the TMP folder/directory to the Newdir directory.

RM Delete command

RM Linux commands are used to remove/delete files in the directory.


Grammar is

RM [command Switch ...] [File | directory]

Command switch:

-F Deletes all files under the directory without prompting the user.
-I. Interactive mode. With this option, the RM command prompts the user for confirmation before deleting any files.
-R (or)-R The directory in the recursive delete parameter table and its subdirectories. The directory will be emptied and deleted. The user is usually prompted when deleting a write-protected file contained in a directory.


Remove/delete file:

RM file1.txt

Here the RM command removes/deletes file file1.txt.

To delete a directory tree:

Rm-ir tmp

Here the RM command recursively deletes the contents of all subdirectories under the TMP directory, which prompts you for deletion of each file, and then deletes the TMP directory itself.

Delete multiple files at once.

RM file1.txt File2.txt

RM command deletes both files File1.txt and file2.txt.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.