Document directory
- Commands for copying, moving, and deleting Ubuntu files
For commands for copying, moving, and deleting Ubuntu files, let's talk about the CP command first.
This command is used to copy the given file or directory to another file or directory. It is very powerful like the Copy command in msdos.
Syntax: CP [Option] source file or directory target file or directory
Note: This Command copies the specified source file to the target file or multiple source files to the target directory.
The options of this command are as follows:
-A this option is usually used when copying directories. It retains links and file attributes, and Recursively copies directories. Its role is equal to the combination of DPR options.
-D: the link is retained during copy.
-F delete an existing target file without prompting.
-I and F options are opposite. A prompt is displayed asking the user to confirm before overwriting the target file. When the answer is Y, the target file will be overwritten, which is an interactive copy.
-P in addition to copying the source file content, CP also copies the modification time and access permissions to the new file.
-If the source file provided by R is a directory file, CP will recursively copy all subdirectories and files in the directory. The target file must be a directory name.
-L do not copy, but only link files.
It should be noted that, in order to prevent the user from using the CP Command inadvertently to destroy another file, such as the target file name specified by the user already exists, use the CP command to copy the file, this file will be overwritten by the new source file. Therefore, we recommend that you use the I option when using the CP command to copy the file.
Then the RM deletion command
You can use the RM command to delete unnecessary files. This command is used to delete one or more files or directories in a directory. It can also delete a directory and all its files and subdirectories. For linked files, the link is closed, and the original file remains unchanged.
The common format of the RM command is:
Rm [Option] file...
If the-r option is not used, RM will not delete the directory.
The options of this command are as follows:
-F ignores non-existing files and never gives a prompt.
-R indicates that Rm recursively deletes all directories and subdirectories listed in the parameter.
-I.
Be careful when using the RM command. Because once a file is deleted, it cannot be recovered. To prevent this situation, you can use the I option to confirm the files to be deleted one by one. If you enter y, the file will be deleted. If you enter anything else, the file will not be deleted.
Finally, the MV mobile command
You can use the MV command to rename a file or directory or move the file from one directory to another. This command is like a combination of Ren and move in msdos.
Syntax: MV [Option] source file or directory target file or directory
Description
Note: depending on the type of the second parameter in the MV command (whether it is the target file or the target directory), the MV command renames the file or moves it to a new directory. When the second parameter type is file, the MV command
After the file is renamed, only one source file (or the source directory name) can be used to rename the source file or directory to the specified target file name. When the second parameter is an existing Directory Name
There can be multiple file or directory parameters. The MV command moves the source files specified by each parameter to the target directory. When a file is moved across file systems, the MV first copies the file, then deletes the original file, and links it to the file.
It will also be lost.
The meaning of each option in the command is:
-I interactive operation. If the MV operation will overwrite the existing target file, the system will ask whether to rewrite the file and ask the user to Answer Y or N. This will avoid overwrite the file by mistake.
-F prohibit interactive operations. When an MV operation overwrites an existing target file, no instructions are given. If this option is specified, the I option will no longer work.
If the target file (not a directory) already exists, the content of the file will be overwritten by the new file. To prevent the user from using the MV command to destroy another file, it is best to use the I option when using the MV command to move the file.