Linux File (folder) creation, copying, moving (rename), deleting command tutorial, linux rename
Ubuntu
Ctrl + Alt + T (Terminal)
1. Create (mkdir)
Syntax format: mkdir [Option] DirName
The [Options] in the Command generally have the following two types:
-M is used to set the access permission for the new directory. You can also use the chmod command to set the access permission.
-P is required to create upper-level folders (or directories), even if these folders (or directories) already exist, it is not considered as an error.
Create demo1 where everyone has the permission to read, write, and execute:
Ii. Copy (cp)
Syntax format: 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] in the Command generally include:
-R,-r, -- recursive Recursively copies all contents in the directory and Its subdirectories.
-F, -- force: delete an existing target file without prompting.
-I, -- interactive, and f options are opposite. A prompt asking the user to confirm is given before overwriting the target file. When the answer is y, the target file will be overwritten, which is an interactive copy.
Create a new a.txt file:
Copy a.txt to the demo1 file:
Iii. Mobile (rename) mv
Syntax format: mv [Option] source file or directory target file or directory
The [Options] in the Command generally include:
-F, -- do not ask before force overwrite (default)
-I, -- ask before interactive Overwrite
Rename: the target file name is different from the source file name, which can be renamed.
Move a.txt in the demo folder to the demo1 file (overwrite)
Iv. Delete (rm)
Syntax format: rm [Option] file...
The [Options] in the Command generally include:
-F, -- force Delete ignore non-existing files and never give a prompt.
-R,-r, -- recursive recursively deletes all directories and subdirectories listed in the parameter.
-I, -- ask before interactive deletion.
Delete a.txt in the demo1 Folder:
Note: Be careful when using rm-rf. There is no recycle bin in linux.