what
Need to install an environment on the server? Edit the configuration file? View run logs? Command to time square hate less.
Have what good
Force is the programmer’s life. And the Linux command line actually works pretty well I think. At the same time continue to expand their boundaries, outward extension. Be the best prepared to be the best you can be (can I be a programmer motivator now?). Start with some basic Linux commands.
File management
Ls = list // Displays files or folders under a directory or current directory ls Directory name // Displays directory ls under a specified folder-a// View the hidden file ls-l// View the file details, file permission - file owner - File owning group - File size (bytes)- file last modified time ls -lh // Same as above, view the file details, but the file size is displayed in an easy-to-read wayCopy the code
Text manipulation
Cat file name // Output the file to the console (not applicable to large files) head -n file name // If n is any number, you can view the first n lines. Tail -n file name // If n is any number, you can view the last n lines-fLess file name // Display the first screen of the file first,shift+ G jumps to the end of the file, G jumps back to the first screen of the file, enter the line number + G jumps to the specified line, /+ keyword (press n to display the next match,shift+n displays last match), CTRL + U to scroll up, CTRL + D to scroll downCopy the code
Grep keyword file name // You can use a simple regular expression to match a keyword. Grep -color Keyword file name // Add a color to the matched keyword to make it more conspicuous. Egrep // You can use a more powerful regular expressionCopy the code
Sort file name // Sort file contents in lexicographical ascending order sort file name -r // Sort file contents in reverse order sort file name -k // Sort a column sort file name -n // Sort by numberCopy the code
Uniq -c: uniq -c: uniq -c: uniq -c: uniq -c: uniq -c: With must be next to separate words count are not allowed to sort the file name | uniq -c / / tips, sorting first, go to heavy, Can solve the above problem sort file name | uniq -c | sort k1, 1 nr | head / / see the top 10 lines occurrencesCopy the code
Wc file name // word count Indicates the number of lines, words, and bytes in a file-lWc -c File name // View only the number of bytesCopy the code
Vim
- Mode switching (command mode/Edit mode/bottom line command mode)
- The cursor
- Delete/copy/paste/insert
- Text search
- Exit the preservation
Vim file name // G to the end of the file, gg to the beginning of the file, /+ keyword to find the specified keyword (n down, n up), d // move the cursor to delete a character dw // delete a word. Dd // delete a line, u can undo the previous operation p // paste, I // Enable insert/edit mode A // Insert after the current character A // Insert ESC at the end of the current line // Return to command mode from edit mode: // Enter the bottom command mode :q // exit current file :w // save current file, add exclamation mark! Force save :wq // Save and exit. The abbreviation is xCopy the code
Packaging and compression
- gzip / bzip2
- tar
- zip
- Zcat/zgrep/zmore/zless(Check the contents of gzip package)
Tar -zcvf tartest. TGZ tarTest/ // Compress the tarTest folder into a. TGZ file. TGZ represents the tar package compressed by gzip. Tar -tvf tartest. TGZ // displays the contents of the compressed fileCopy the code