The commands for copying, moving and deleting files under linux are: cp, mv, rm
First, the file copy command cp
Command format: cp [-adfilprsu] source file (source) destination file (destination)
cp [option] source1 source2 source3 ... directory
Parameter Description:
-a: means archive, also means copying all directories
-d: If the source file is a link file, copy the link file attributes instead of the file itself
-f: Force (force), if there are repetitions or other questions, the user will not be asked, and the copy will be forced
-i: If the destination file (destination) already exists, it will first ask if it really operates when overwriting
-l: Establish a hard link to the connection file instead of copying the file itself
-p: copy with file attributes instead of default attributes
-r: recursive copy, for directory copy operations
-s: Copy into a symbolic link file (symbolic link), that is, a "shortcut" file
-u: If the target file is older than the source file, update the target file
If you copy file1 in 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
Second, the file move command mv
Command format: mv [-fiv] source destination
Parameter Description:
-f:force, force direct move without asking
-i: If the destination file (destination) already exists, it will ask whether to overwrite
-u: If the target file already exists and the source file is relatively new, it will be updated
If you copy file1 in 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
3. File deletion command rm
Command format: rm [fir] file or directory
Parameter Description:
-f: force delete
-i: interactive mode, ask the user for an operation before deleting
-r: recursive deletion, commonly used in directory deletion
To delete the file1 file in the /test directory, you can enter the following command:
rm -i / test / file1