Linux-(2) Basic file operations in Linux, linux-linux
In linux, everything is files, directories are files, and hardware is files. Therefore, basic file operations are especially important.
1. List the contents of the directory:
Ls <Directory Name> does not add a directory name to list the current directory
Parameters:
-A: displays all files (including hidden files)
-L display details
-R recursive display subdirectory Structure
-Ld: displays directory and link information
2. view the file information:
File <file Name>
3. Switch the directory:
Cd <path>
"..." Upper-level directory
"." Current Directory
"~ "Home Directory of the currently logged-on user
"-" Previous working directory
4. Create a file:
Touch <File Name> the touch command can create an empty file or update the time of an existing file.
5. Create a folder:
Mkdir <folder Name>
6. copy the file, directory:
Cp <source file/folder> <target file/folder>
Parameters:
-R Recursively copies the entire directory tree
-V: Show Details
7. Move and rename the file or directory:
Mv <File> <target directory>
If the file name is specified, You can rename the file.
8. delete an object:
Rm <file/folder>
Parameters:
-I interactive (every file will prompt whether to delete)
-R recursively deletes all contents in the directory.
-F force Delete, no warning prompt
9. delete an empty folder:
Rmdir <folder> This command cannot delete non-empty folders. Use the previous rm-r