Linux basics 03_Linux file basic operation management

Copy files and directories (cp command)

cp命令Copy files or directories using

Command format:cp 源文件(或文件夹) 目标文件(或文件夹)

Common parameters:

  • -rCopy the entire folder (including all files inside)
  • -vDisplay detailed information during the copy process, such as: copy progress

example

  1. In the same folder (TestDirectory), copy "File Basic Operation Management.txt" and rename it to "Hey Hey Hey Hey Hey Hey Hey Hey.txt":
    cp under the same folder
  2. 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)

cp to a different folder

  1. Copy the "TestDirectory22222" folder and rename it to "la la la la la" (use -rparameters)
    cp copy folder
    Use -vparameters 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"
    -v parameter

Move, rename files or directories (mv command)

mvMove or rename files or directories by command

Command format:mv 文件 目标目录

If filename is specified, the file can be renamed

example:

  1. Move the nash_su file in the root directory to the TestDirectory folder:
    mv nash_su TestDirectory/

mv1

  • 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
    mv2

  • 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 我现在叫这个名字啦
    mv3

Create, delete files (touch, rm)

  • touch命令You can create an empty file or update the file time by
  • rm命令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 -rithe command, when deleting the folder, Linux will ask whether to delete each file, enter yes to confirm the deletion, such as picture:
rm1

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

Guess you like

Origin blog.csdn.net/Waldocsdn/article/details/105271261