Linux Introductory Training Tutorials

Source: Internet
Author: User

  

Linux Introductory Training Tutorials

Linux under copy CP delete RM move MV command parameters and description

Copy move delete looks so simple in Windows, but Linux often uses the text interface, so for Linux system copy CP delete RM move MV command parameters you have to understand and learn

Cp

The function of this command is to copy the given file or directory to another file or directory, which is as powerful as the copy command under MSDOS.

Syntax: CP [option] source file or directory destination file or directory

Note: This command copies the specified source files to the destination file or copies multiple source files to the destination directory.

The options for this command have the following meanings:

-A This option is typically used when copying a directory. It retains links, file attributes, and recursively copies the directory, which is equal to the combination of the DPR option.

-Keep links when copying D.

-F Delete a target file that already exists without prompting.

-I and F options, in contrast, will prompt the user for confirmation before overwriting the target file. Answer y when the target file will be overwritten, is an interactive copy.

-P At this point, the CP will also copy the modified time and access rights to the new file in addition to the contents of the source file.

-R If the source file is a directory file, the CP will recursively replicate all subdirectories and files in that directory. The destination file must be a directory name at this time.

-L do not make copies, just link files.

It should be explained that in order to prevent the user inadvertently using the CP command to destroy another file, such as the user specified target file name already exists, the CP command after copying the file, the file will be overwritten by the Xinyuan file, it is recommended that users use the CP command to copy files, it is best to use the I option.

MV Command

Users can use the MV command to rename files or directories or to move files from one directory to another. This command is like the combination of Ren and move under MSDOS.

Syntax: MV [options] source file or directory destination file or directory

Description: Depending on the second parameter type in the MV command (target file or target directory), the MV command renames the file or moves it to a new directory. When the second parameter type is a file, the MV command completes the file rename, at which point the source file can only have one (or the source directory name), which renames the given source file or directory to the specified destination file name. When the second parameter is a directory name that already exists, the source file or directory parameter can have more than one, and the MV command moves the source files specified by each parameter to the destination directory. When you move a file across a file system, the MV copies the original file, and the link to the file is lost.

The meanings of the options in the command are:

-I interact with the mode of operation. If the MV operation will cause an overwrite of the target file that already exists, the system asks whether to rewrite and asks the user to answer Y or N, which avoids overwriting the file by mistake.

-F prohibit interactive operation. When the MV operation is to overwrite an existing target file without giving any indication, when this option is specified, the I option will no longer work.

If the given destination file (not the directory) already exists, the contents of the file will be overwritten by the new file. To prevent users from destroying another file with the MV command, it is best to use the I option when moving a file using the MV command.

RM command

Users can use the RM command to delete unwanted files. The function of this command is to delete one or more files or directories in a directory, and it can delete all files and subdirectories under a directory. For linked files, only the link is broken, the original file remains unchanged.

The general form of the RM command is:

RM [Options] File ...

If the-r option is not used, RM does not delete the directory.

The options for this command have the following meanings:

-F Ignore nonexistent files and never give hints.

-R instructs RM to delete all directories and subdirectories listed in the parameter recursively.

-I do an interactive delete.

Use the RM command with caution. Because once the file is deleted, it cannot be restored. To prevent this from happening, you can use the I option to confirm the files you want to delete individually. If the user enters Y, the file is deleted. If you enter anything else, the file is not deleted.


Linux Introductory Training Tutorials

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.