Linux basic commands and linux commands
Ls command
Pwd: display the current directory touch 11.txt: Create a txt file named 11 mkdir laowang under the current directory: Create a folder named laowang ls-a-l-h in the current directory: it is equivalent to ls-alh.-a is used to display all files in the current directory, including hidden files.-l is displayed as a list, -h is the size of the displayed file automatically converted to the default format, such as 10 K, 10 M, 10G. the Parameter order does not matter. history: displays commands executed in history ,! 102: Execute the history command rm 11.txt: delete the file ls 2 * whose name is 11.txt in the current directory. The file or folder starting with 2 is displayed, and * is a wildcard, * replace 0 or n ls 2? : Displays files or folders that start with 2 and are followed by only one digit ,? Replace an ls 1 [1234] 8: equivalent to ls 1 [1-4] 8, displaying a file or folder named 118,128,138,148
Cd command
Cd...: Back to the upper-level directory cd of the current directory.: Back to the current directory cd-: Jump to the last directory cd ~ : Jump to the user's home directory
Merge file content-Write File
Ls> xxx.txt: The cursor does not exist. automatically create ls> xxx.txt: add the content displayed on the top of the cursor to the more xxx.txt file under the xxx.txt file: The content of xxx.txt is displayed on the cursor. Different from cat, more can be displayed on pages, B is the previous page. cat 111.txt 222.txt> xxx.txt: merges 111.txtand 222.txtinto xxx.txt.
Folder operations, soft links, and hard links
Mkdir A/B/C/D/E-p: Create folder A in the current directory, create folder B in folder A, create folder C in folder B, and so on. Tree: displays the structure of the current directory in the form of A tree: rmdir C: deletes the folder named C under the current directory, and can only delete the empty folder rm A-r: delete the folder named A in the current directory. It is not necessarily an empty folder. Recursive deletion of mv 1.txt 2.doc: after you rename 1.txtname as 2.doc ln-s 1.txt 1softlink.txt: Success, 1softlink cannot be used. Ln 1.txt 1hardlink.txt: Creates a hard link named 1hardlink.txtfor 1.txt. After deleting 1.txt, 1hardlink can still be used.
Grep searches for file content, copying and cutting files
Grep 22 xxx.txt: Search for rows containing 22 in the xxx.txt file (search for content in the file) mv xxx.txt A: Convert the file named xxx.txt to cp xxx.txt A in the folder named: copy the file named xxx.txt to A folder named.
Find command
Find/-name "* name": search for all files suffixed with name in the root directory find. /-name "* name": search for all files suffixed with name in the current directory find/tmp-size 2 M: find/tmp-size + 2 M for files equal to 2 mb in the/tmp directory: find/tmp-size-2 M for files larger than 2 mb in the/tmp directory: find the file smaller than 2 mb in the/tmp directory. /-size + 4 k-size-5 M: find Files larger than 4 K in the current directory and smaller than 5 M (Note: uppercase M, lowercase k) find. /-size 1G: Search for files equal to 1 GB in the root directory (Note: G is capitalized)
Tar compression and decompression
Tar-cvf test.tar *: Pack all files and folders in the * Directory into test.tar-xvf test.tar: Decompress the compressed file test.tar under the current directory.