Linux's basic command - File operations

ls (show the contents of the specified working directory)

  • -a show all files, including hidden files and directories
  • -l In addition to the file name, but also the file type, permissions, owner, file size and other information detailing [can] ll shorthand
  • -r file will display in the reverse order (the default is az)
  • -t by file creation time, from morning till evening lists
  • -A with -a, but does not list "." (Current directory) and ".." (parent directory is the parent directory)
  • -F file names listed after adding a symbol; then add executable e.g., "*", then add the directory "/"
  • -R recursive view.
  • ls -l -h show in detail the current directory files, and file size to more clearly show the way. -l shows the file size in bytes, and may be displayed in -h K, M and other units.

mkdir (create directory)

  • Creating wuzm directory: mkdir wuzm [rather] windows in the new folder
  • -p recursively create directory: mkdir -p wuzm / a / b / c

cd (change the current working directory to the specified directory)

cd back can take an absolute path, relative path can also be connected, if the latter do not take any cd path, the default back to the user's home directory is equivalent to cd ~. [Equivalent to the windows in the folder, double-click to enter]

  • "~" Represents the home directory of meaning,
  • . "" Is a directory is currently located,
  • ".." indicates that the current directory location of the parent directory
  • cd ../../ .. Return Level 3

pwd (show the path of the current directory)

touch (create file)

  • touch File Name: touch 0608.txt
  • touch {a..z} .txt create a batch file

mv (move files)

  • Music Videos <file to be moved> <moving target address>: mv 0608.txt wuzm / a
  • Multilayer directly write the whole directory to the target address
  • mv abc aaa: the abc renamed aaa
  • mv abc / * .      to all files in the directory abc, move to the current directory

cp (copy a file or directory)

  • -a: This option is typically used when copying a directory, it retains links, file properties, and copy all the contents of the directory. (Full copy)
  • -f: overwrite the destination file already exists, without prompting.
  • -i: In contrast with the -f option, prompt before overwriting the destination file, ask the user to confirm whether to overwrite the answer target file will be overwritten when "y".
  • -p: In addition to copying the contents of the file, the time and also modify the access rights are also copied to the new file.
  • -r: If the source file is given a file directory, recursively copy.
  • cp <filename> <you want to copy to the path>: cp adb.txt a

rm (delete a file or directory)

  • -I before asking each deletion confirmation.
  • -f even if the original file is set to read-only property, also delete, one without confirmation.
  • -r directory and the files also removed one by one.
  • RM aaa /         RM does not take parameters can not delete the directory, only family - r before you can delete the directory
  • RM - RI aaa /    When you remove each one asking if the user deletes
  • RM - the RF aaa      delete aaa directory and do not ask
  • RM - the RF *           delete all files in the current directory
  • Once the file by rm command to delete, you can not recover, not to run away from deleted files

rmdir (remove empty directories)

  • -p When deleting subdirectories, after the current directory becomes empty, the current directory is also deleted

* On behalf of all of GM match

 

Guess you like

Origin www.cnblogs.com/wuzm/p/10991580.html