Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the basic commands in Linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "what are the basic commands in Linux", which is easy to understand and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn this article "what are the basic commands in Linux?"

What's the advantage?

Forcing the grid is the foundation of the programmer. And actually, the Linux command line works pretty well, I think. At the same time, it continues to expand its boundaries and extend outward. Be the best prepared to be a better you (can I be a programmer motivator?). Let's start with some basic Linux commands.

Document management

Ls = list / / Show a directory or a file or folder under the current directory ls folder name / display the directory under the specified folder ls-a / / View the hidden file ls-l / / View the file details, file permissions-who the file belongs to-the group the file belongs to-the file size (bytes)-the last modification time of the file ls-lh / / ditto, view file details But the file size is displayed in an easy-to-read way

Text operation

Cat file name / / output the file to the console (not applicable to large files) head-n file name / / n is any number, indicating that you can view the first n lines of tail-n file name / / n is any number, indicating that you can view the last n lines of tail-f file name / / view the file more file name being written in real time / / not only want to see the beginning and end of the file, but also want to see more contents of the file. The disadvantage is that you can only flip forward, cannot flip back the less file name / / first display the first screen of the file, shift+ G jumps to the end of the file, g jumps back to the first screen of the file, enter the line number + g to jump to the specified line, / + keyword (press n to show the next match, shift+n shows the previous match), ctrl+u page up, ctrl+d page down grep keyword file name / / view the specified keyword content in the file You can use a simple regular expression to match the keyword grep-color keyword file name / / add color to a pair of matched keywords More conspicuous egrep / / can use the more powerful regular expression sort filename / / A pair of file contents are sorted in ascending dictionary order sort filename-r / / A pair of file contents are sorted in reverse order sort filename-k / / specifies a column to be sorted by sort filename-n / / sort uniq / / unique by number, remove the repeat command, and output uniq-c / / only once except for this line if there is a peer Also output the number of occurrences of this line. Restrictions: the same line must be next to each other. If you count separately, the sort file name is not allowed | uniq-c / / Tip, sort first, and then remove the duplicate, you can solve the above problem sort file name | uniq-c | sort K1J 1nr | head / / check the first 10 lines of copy code wc file name / / word count to count the number of lines and words in the file. Number of bytes wc-l filename / / number of lines only wc-c filename / / number of bytes only

Vim

Mode switching (command mode / edit mode / bottom line command mode)

Cursor movement

Delete / copy / paste / insert

Text search

Exit Save

Vim file name / / G jumps to the end of the file, gg jumps to the beginning of the file, / + keyword looks for the specified keyword (n down, N up), d / / move the cursor to delete a character dw / / delete a word, in fact, the deletion mentioned in this refers to cut, save to buffer to dd / / delete a line, u can undo the operation p / / paste I / / turn on insert / edit mode a / / insert A / / insert esc / at the end of the current line at the end of the current line / return to command mode from edit mode: / / enter the bottom line command mode: Q / / exit the current file: W / / save the current file, add an exclamation mark! Force save: wq / / Save and exit, abbreviated as x

Packaging and compression

Gzip / bzip2

Tar

Zip

Zcat / zgrep / zmore / zless (view the contents of the gzip package)

Tar-zcvf tarTest.tgz tarTest/ compress the tarTest folder into a file in .tgz format. Tgz represents a tar package compressed using gzip. The parameter-z represents gzip compression, c represents compression, v represents compressed information, and f indicates to overwrite its tar-tvf tarTest.tgz / / display the contents of the compressed file if the file exists The advantage of not unpacking tar-xzf tarTest.tgz / / unzipped package / / tar is that it can save a lot of information. These are all the contents of the article "what are the basic commands in Linux?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report