Home > Operation and Maintenance > Linux Operation and Maintenance > Programmers must master 59 commonly used Linux commands

Programmers must master 59 commonly used Linux commands

坏嘻嘻
Release: 2018-09-15 15:39:09
Original
1925 people have browsed it

The content of this article is about 58 commonly used commands in Linux. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

  1. Quick start terminal: ctr alt t

  2. Enlarge terminal font: ctr shift ' '

  3. Terminal font reduction: ctr '-'

  4. ls: View the file information of the current directory

  5. pwd: View the path of the current directory

  6. touch: Create file

  7. mkdir: Create folder

  8. rmdir: Delete empty folder

  9. rm: Files are deleted by default. -r means to recursively delete all file information in the folder and finally delete the folder

  10. cd Switch directory 10.1 cd directory name: Switch to the specified directory 10.2 cd ..: Switch to the upper level directory 10.3 cd .: Switch to the current directory 10.4 cd ~: Switch to the user's working directory 10.5 cd -=> cd ~ : Switch to the user's working directory 10.6 cd -: Switch to the last directory

  11. clear :Clear screen->window : cls

  12. Absolute path: The path starting from the root directory is called an absolute path -> cd /home/python

  13. Relative path: The path starting from the current directory is called a relative path -> cd ../test cd ./test

  14. Summary on the use of absolute paths and relative paths: If the directory being switched is close to the root directory, use the absolute path. If the directory being switched is close to the current directory, use the relative path. , if the directory being switched is not close to the current directory and the root directory, use the absolute path

  15. cp: copy 15.1 cp file name path: copy the file to the specified directory 15.2 cp file name Path/new file name: Copy the file to the specified path and then modify it to the new file name 15.3 cp file name new file name: Copy the file to the current directory and modify it to the new file name 15.3 cp Folder path -r : Copy the folder to the specified path -r: Copy all the files in the folder recursively

  16. mv: Move (cut) 16.1 mv file name path : Move the file to the specified directory 16.2 mv file name path/new file name: Move the file to the specified path and modify it to the new file name 16.3 mv file name new file name: Rename the 16.4 mv folder path: Move the folder to the specified path

  17. tree: View directory information in the form of a directory tree 17.1 tree path: View directory tree information in the specified path

  18. cal: View the current month calendar 18.1 cal -y: View the full year calendar information

  19. date: View the current time 19.1 Time format: date " %Y-%m-%d %H:%M:%S": Year, month, day and ten seconds

  20. history: View historical command 20.1! Historical command number: Execute the corresponding historical command

  21. Command format: 21.1 Command name options parameters, prompt options can sometimes be placed after the parameters, but if an error is reported, you can consider placing them after the command, such as: scp -r 21.2 Options: For example: -r, The options may have 0 or more 21.3 Parameters: file name or path, the parameters may have 0 or more

  22. Command name --help: View help information

  23. man Command name: View help information 23.1 f Space: View next page 23.2 b: View previous page 23.3 Enter: View next line 23.4 q: Exit

  24. rm: Option 24.1 -i: Reminder before deletion 24.2 -r: Recursively delete all file information in the folder 24.3 -f: If the file does not exist, no error message is displayed when deleting 24.4 -v: Display deletion description information 24.5 -d: Delete empty directory

  25. ls option 25.1 -l: Display in list form 25.2 -a: Display hidden files 25.3 - h: Display file size unit

  26. ##ll -> ls -al

  27. l -> ls

  28. mkdir options: 28.1 -p: Create the required folders in advance

  29. cp options 29.1 -i: Display reminder 29.2 -r: Recursively Copy the folder 29.3 -f: Direct overwrite 29.4 -v: Display the copied path description

  30. mv options: 30.1 -i: Display reminder 30.2 -f: Direct overwrite 30.3 -v: Display the moved path description

  31. Redirection (>,>>): Rewrite the specified display direction, save the data displayed on the terminal to a file, and view the data later View through files 31.1 >: If the file exists, the original data will be cleared first and then new data will be written, which is equivalent to file operation: w 31.2 >>: If the file exists, then it will be performed based on the original data. Append writing data is equivalent to file operation: a Summary: ls, tree, cat collection redirection uses

  32. gedit: command of text editing tool, readable and writable

  33. cat: View the data in the file in the terminal, read-only

  34. more: Split screen display 34.1 f (space): See the next page 34.2 b: Look at the previous page 34.3 Enter: Look at the next line 34.4 q: Exit

  35. | Pipeline: Can be understood as a container for data 35.1 Note: You cannot look at the previous page when using the pipe in combination with more Page: b shortcut key does not work 35.2 ls, tree cat can be used in combination with pipes

  36. File merging 36.1 cat 1.txt 2.txt > 3.txt

  37. Link: Soft link: Just like a shortcut, note: deleting the original file soft link is invalid, creating a soft link will not increase the number of hard links by 1, you can create a soft link in a directory. Very important note Point: If the soft link is not in the same directory as the original file, then the original file needs to use the absolute path of the soft link: ln -s 1.txt 1-s.txt, ln -s /home/python/Desktop/AAA /1.txt ../1-s.txt By default, search

  38. in the current directory

    Hard link: Just like a person can have multiple names, deleting the original file will not affect the hard link file. File data can still be obtained using hard link files. Note: Hard links cannot be created for directories. Creating a hard link can only be created for files. Creating a hard link will increase the number of hard links by 1. Use of hard links: ln 1.txt 1-h.txt

  39. grep: Find data based on search content 38.1 -n: Display line number 38.2 -v: Negate based on search content 38.3 -i: Ignore case

  40. find: Search for files based on the specified path 39.1 -name: Search based on the file name 39.2 -size: Search based on the file size, please note that it is not accurate and generally not used 39.3 -perm: Search based on permissions r:4 w:2 x:1 find . -name "*.txt" -> Search for files with .txt suffix. Wildcard: plays the role of fuzzy query, * means matching 0 or more characters, ?: can only match any character, Tip: Wildcards have nothing to do with regular expressions

  41. ls. Use it in combination with wildcards. For example: ls *.txt

  42. ##tar to package 41.1 tar -cvf test .tar *.txt -> test.tar package, please note that the space will not become smaller because it is not compressed

  43. gzip compression 42.1 gzip test.tar -> test.tar.gz Compressed package, the space will become smaller

  44. tar packaging and compression (must master) 43.1 tar -zcvf test.tar.gz *.txt -> test.tar.gz compressed package 43.2 -z: Compression -c: Packaging -v: Display the packaged file f: Specify the file name

  45. gzip Decompress 44.1 gzip -d test.tar.gz -> test.tar package

  46. tar Unpack 45.1 tar -xvf test.tar -> Files in the package 45.2 -x: Unpack

  47. tar Unpack and unpacking (must master) 46.1 tar -zxvf test.tar.gz -> Decompress and unpack the file 46.2 tar -zxvf test.tar.gz -C path -> Decompress and unpack the compressed package to the specified path

  48. bz2 Pack and compress -jcvf test.bz2 *.txt -> test.bz2

  49. bz2 Unzip and unpack 48.1 tar -jxvf test.bz2 -> Get the file 48.2 in the compressed package tar -jxvf test.bz2 -C path -> Decompress and unpack the compressed file to the specified path

  50. zip packaging and compression 49.1 zip test[.zip optional] *.txt -> test.zip

  51. unzip decompression and unpacking 50.1 unzip test.zip -> get the solution Compressed and unpacked files 50.2 unzip test.zip -d path -> Decompress and unpack to the specified path 50.3 Summary: zip compressed packages take up the largest space, and generally use .gz and bz2

  52. chmod: Modify file permissions 51.1 User role: u: Current user g: User in the same group o: Other users a: All users 51.2 Permissions: r(4): Readable w(2): Writable x( 1): Executable - (0): No permission 51.3 chmod a=rwx 1.txt, chmod a=- 1.txt, chmod a= 1.txt, chmod 777 1.txt chmod 000 1.txt 51.4 Different users are different Permissions: chmod u=r,g=w,r=rwx 1.txt, chmod 427 1.txt

  53. cp option-a: retain file permissions, mainly for other users Permissions, Tip: -a contains the -r option, you can also copy the folder

  54. which: Get the path of the command

  55. sudo -s: Switch to the administrator user

  56. whoami: current user

  57. who: those users currently logged in

  58. passwd:Change password

  59. exit:Exit account

The above is the detailed content of Programmers must master 59 commonly used Linux commands. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template