Linux common instructions (directory operation)

pwd

[plain]  view plain copy  
  1. pwd View the full path of the current directory  

cd - adjust location (go back, open folder, etc.)

[plain]  view plain copy  
  1. cd directory name: open the specified directory  
  2.   
  3. cd ~: Open the current user's home directory  
  4.   
  5. cd ..: go back to the previous directory  
  6.   
  7. cd -: return to the directory  
  8.   
  9. cd /: open the root directory  

ls - displays all files and folders in the current path

[plain]  view plain copy  
  1. ls -l: View the list of files in the current directory in one column  
  2.   
  3. ls -a: View all files in the current directory (including hidden files)  
  4.   
  5. ls -la: View all files in the current directory in a list  

mkdir - create file directory

[plain]  view plain copy  
  1. mkdir folder name: create folder  
  2.   
  3. mkdir -p: recursively create a multi-level directory  

rmdir - delete file directory

[plain]  view plain copy  
  1. rmdir directory name: delete the specified directory  
  2.   
  3. rmdir -p directory name: recursively delete the specified directory and intermediate directories  

rm - delete a file or directory

[plain]  view plain copy  
  1. rm -f: Force delete the specified file  
  2.   
  3. rm -i: ask to delete before deleting  
  4.   
  5. rm -r: delete recursively  
  6.   
  7. rm -rf directory or file: force delete a file or directory  
  8.   
  9. rm -ri directory or file: ask for confirmation to delete before deleting  
  10.   
  11. Note: Because the lethality of forced deletion is too great, it is generally not recommended to use rm -rf for file deletion;  
  12.      Without the r parameter in the rm command, the directory cannot be deleted, only the file can be deleted.  

cp - copy a file or directory

[plain]  view plain copy  
  1. cp -r: recursive continuous copy, for the copy behavior of directories  
  2.   
  3. cp -f: Forced copying, when there are repetitions or other doubts, the user will not be asked, and the forced copying will be performed directly  
  4.   
  5. cp -p: save attributes of source files and directories  
  6.   
  7. cp -i: ask user before overwriting existing directory  
  8.   
  9. cp -r directory 1 directory 2: recursively copy all files and folders of directory 1 to directory 2  
  10.   
  11. cp -ri directory 1 directory 2: ask the user before overwriting the original directory when performing a copy operation  

mv-move file (cut), modify file name

[plain]  view plain copy  
  1. mv -b: If the file is overwritten, back up before overwriting  
  2.   
  3. mv -f: force overwrite if target file already exists  
  4.   
  5. mv -i: If the target file exists, it will ask whether to overwrite  
  6.   
  7. mv file 1 file 2: change the name of file 1 to file 2) (rename the file)  
  8.   
  9. mv directory 1 directory 2: move the files of directory 1 to directory 2 (move the files of directory 1 to directory 2)  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325992394&siteId=291194637