Article directory
Copy files and directories (cp command)
cp命令
Copy files or directories using
Command format:cp 源文件(或文件夹) 目标文件(或文件夹)
Common parameters:
-r
Copy the entire folder (including all files inside)-v
Display detailed information during the copy process, such as: copy progress
example
- In the same folder (TestDirectory), copy "File Basic Operation Management.txt" and rename it to "Hey Hey Hey Hey Hey Hey Hey Hey.txt":
- Copy the "file basic operation management.txt" under the "TestDirectory folder" to the "TestDirectory22222 folder" (because it is not in the same folder, so there is no need to rename it)
- Copy the "TestDirectory22222" folder and rename it to "la la la la la" (use
-r
parameters)
Use-v
parameters to display detailed information when copying the folder, including the copy progress of each file in the folder:
Copy "TestDirectory22222" Folder, and renamed to "la la la la la 33333"
Move, rename files or directories (mv command)
mv
Move or rename files or directories by command
Command format:mv 文件 目标目录
If filename is specified, the file can be renamed
example:
- Move the nash_su file in the root directory to the TestDirectory folder:
mv nash_su TestDirectory/
-
Still the above example, if I want to move the file nash_su from the root directory to the TestDirectory folder and rename it to cast
mv nash_su TestDirectory/cast
-
Following the above example, in the TestDirectory folder, now I don’t want to move the cast file out of the folder, I just want to change the name, just change the third parameter to the desired file name
mv cast 我现在叫这个名字啦
Create, delete files (touch, rm)
touch命令
You can create an empty file or update the file time byrm命令
Files or directories can be deleted through
common parameters:
-i interactive
-r deletes all content in the folder, including the folder itself
-f force deletes without warning
When only using the -r command, you can delete the folder and all the contents inside without any prompt;
when using -ri
the command, when deleting the folder, Linux will ask whether to delete each file, enter yes to confirm the deletion, such as picture:
Create and delete directories (mkdir, rmdir, rm -r)
mkdir命令
Create a directory by- By
rmdir命令
removing an empty directory - By
rm -r(-f)命令
deleting a non-empty directory