In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly shows you "what skills are there in Linux", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "what skills are there in Linux" this article.
The software installation command in this paper takes Ubuntu as an example, and other distributions are similar.
1. Jump to directory graceful and smooth 1.1 bd command
Quickly return to a specific parent directory in Bash instead of typing "cd.. /..".
If you are in this path
/ home/radia/work/python/tkinter/one/two, and to quickly change to the directory python, simply type:
Bd python
Or enter only the first few letters of the directory, if you match more than one directory, go back to the nearest one:
Bd p
Example:
Bd command installation:
Sudo wget-- no-check-certificate-O / usr/bin/bd https://raw.githubusercontent.com/vigneshwaranr/bd/master/bdsudo chmod + rx / usr/bin/bdecho 'alias bd= ".bd-si" > ~ / .bashrcsource ~ / .bashrc
To enable case-sensitive directory name matching, use-s instead of-si in aliases:
For more information, you can visit the developer GitHub:
Https://github.com/vigneshwaranr/bd
1.2 some common techniques for cd commands
Cd is returned to the user's home directory without any parameters, which is equivalent to: cd ~.
Cdcd ~
Cd-fallback to the previous directory:
Cd-1.3Custom command, jump to common directory
For frequently used directories, you can add a custom command to achieve one-click direct access. This point will be explained in detail below. Let's take a look at the effect first.
If you are in this path
/ home/radia/work/python/tkinter/one/two, and want to quickly go to the directory / home/radia/work/linux/linux-3.16.6, and then simply type:
Cl
Example:
two。 Multi-terminal operation
In the Linux terminal operation, arbitrarily dividing the screen into multiple windows and reducing mouse operation is a good way to improve efficiency.
Here, Terminator is recommended. Installation method:
Sudo apt-get install terminator
After the installation is complete, CTRL + ALT + T opens the software, or searches for terminator in all programs.
The following figure shows an example of using keyboard shortcuts to split three small windows and rename the lower left window to log.
The three parts divided in this way:
The lower left corner can be specially used to display real-time serial port log.
The upper left can be used to compile code, view compilation errors, etc.
On the right, you can edit the code, browse files, and so on.
Of course, the size of each split screen can also be flexibly adjusted, mouse drag and shortcut keys CTRL + SHIFT + ↑ ↓ ← → can be achieved.
If a tab can not meet the needs, you can use the shortcut key CTRL + SHIFT + T to open multiple tabs, the tab can also edit the title, easy to distinguish.
The commonly used shortcut keys are as follows:
CRTL + SHIFT + T, open a new tab
CRTL + SHIFT + E, vertical split screen
CRTL + SHIFT + O, split screen horizontally
`ALT + ↑ ↓ ← → ``switch between splits in the same tab
CTRL + PAGEUP / PAGEDOWN switch different tabs around
Keyboard shortcuts can also be configured according to their own habits, such as the shortcut key for switching tabs is CRTL + PAGEUP/PAGEDOWN, for such a common operation, the finger moves to the PAGEUP/PAGEDOWN button, the distance is still too long, I am used to configuring it to ALT + H and ALT + L, because the ALT key with the direction key can switch different screens in the same tab, just let ALT switch different tabs. H and T are chosen because they are used to the left and right movement of H and T in Vim.
The efficiency can be improved by reserving a terminal window for common functions and editing the terminal title. Split the window according to your own habits, adjust the window, and then combine the powerful Vim configured in the next section, you can easily create your own and efficient IDE.
3. File Editing 3.1 Markdown Editor recommendation
Markdown is currently the most popular markup language, can give conventional text files: format typesetting, insert pictures, insert charts, insert code and other practical functions, here recommend Typora editor, literary style, powerful function.
Tpyora installation:
Wget-qO-https://typora.io/linux/public-key.asc | sudo apt-key add- # add Typora's repositorysudo add-apt-repository 'deb https://typora.io/linux. /' sudo apt-get update# install typorasudo apt-get install typora
Markdown and Tpyora are easy to use and can be seen at a glance. There is no need to introduce them any more.
You can use Markdown format as a common format for taking notes and organizing your knowledge tree.
Typora official website: https://www.typora.io
3.2 Code editing and viewing
It is generally accepted that the best code editor to use is of course Vim, but many features are a bit cumbersome to configure. It takes a lot of time to compare and study various plug-ins, which is unfriendly for beginners.
This article does not compare any Vim plug-ins to avoid dazzling and falling into choice phobia, but directly attach the Vim configuration package that I have accumulated for many years and have been using it. It is recommended that readers who have not yet formed their own habits to use the version I provide, use it first, and slowly understand it in practical use. I believe that it will not be long before they can get used to Vim, and then adjust or reconfigure according to their own needs.
3.2.1 Vim installation and Quick configuration
Vim installation method:
Sudo apt-get install vim
After downloading and decompressing vim.tar.gz, extract the vim-config.tar to the user root directory:
Tar-xvf vim-config.tar-C ~ /
After installation, it is as simple as that, all the plug-ins have been included in the package, there is no need to download anything else.
Reopen a terminal window and you can use Vim to open the code to see the effect:
As can be seen in the above interface, the left interface is a list of files (not displayed by default, F3 on / off), and the right side is a list of functions (default display, F9 on / off). You can use CTRL + W to jump between areas, and in all three interfaces, you can move the cursor through h, j, k, l, just like editing files.
Press enter on the function list item to jump to the specified function.
Press enter on the file list item to open the corresponding file; press I or s to split horizontally or vertically to open the file, this Vim split window function, view code is very useful.
3.2.2 search for a file
Using F3 outbound file list, it is more convenient to open files in the same directory, but if you need to open files in other locations, you can press F5 to find the file window, enter the file name in the project, and quickly open the file.
3.2.3 Jump to function definition
The essential function of viewing code is to quickly reach the defined location of a function or variable. To do this, you first need to create an index.
Execute under the project root:
Ctags-R * / / or specify the language ctags-languages=c,c++,java-R that needs to be indexed
The execution time depends on the amount of source code in the project, and it takes longer to create an index with more files. After the execution is complete, a tags file is generated in the project and directory. So when you open Vim in that directory again, you can use the CTRL +] shortcut key to jump to the defined location of the function or variable, and use CTRL + T to return to the original location.
3.2.4 other
These basic operations given above can basically meet all the daily needs. If you like to toss around, you can explore more features after you are familiar with it, and you can also speed up the search. These readme in vim.tar.gz also have simple instructions, which can be regarded as throwing a brick to attract jade.
I hope that through the above introduction, you can get used to and like Vim.
This set of configuration turns on the support of the mouse by default, and you can position the focus of the cursor through the mouse and use the scroll wheel to turn the page code, which is for beginners' convenience. After getting familiar with it, it is recommended to turn off this function, because you will lose the right mouse menu after turning on the mouse function, and the mouse is not as efficient as the keyboard operation.
Turn off the mouse function in Vim:
Vim ~ / .vimrc / / put quotation marks before line 303 and comment out set mouse=a to "set mouse=a4. Custom shell command"
The essence of Linux is scripting, which can add logical relationships to common operations, complete a series of operations, and free our hands, which is one of the main reasons why programmers like to use Linux.
4.1 implementation of cl command
Let's take a look at the cl command mentioned above, which can quickly jump to the commonly used Linux source directory. how does this work?
It's incredibly simple: just add a command alias to the .bashrc file at the current user's root.
Try it according to the following command and put it into one of the
Replace / home/radia/work/linux/linux-3.16.6/ with your own common path:
Echo 'alias cl= "cd / home/radia/work/linux/linux-3.16.6/" > ~ / .bashrcsource ~ / .bashrc
As you can see in the above figure, the cl command is not available before it is added, but after it is added, the function can be implemented and successfully jumped to the specified directory.
Note: the above operation only needs to be done once, and all terminals opened after the addition will contain the cl command.
4.2 to try a command with more complex functions
Commands with more complex logic cannot be written directly in the ~ / .bashrc file like the cl above.
Suppose the following scenarios:
When working in A scene, when you need to open the software A1, A2, A3 scene B needed for A scene, you need the support of software B1, B2, B3. Then you can add a command env_switch to complete the switching of such a work environment.
Env_switch A start # turn on the software in the A working environment A1 stop # turn off the software in the A working environment A1 start # open the software in the B working environment B1Magi B2Jing switch B stop # turn on the software in the B working environment B1Magi B2Jing B3
The implementation is as follows:
In any directory, such as / home/radia/cmd, create the script file env_switch.sh.
Add the following, in which echo is used instead of opening and closing the software, and can be replaced by the opening command of the software when in actual use:
#! / bin/bashfunction env_switch () {if [$1 = "A"]; then echo "A1 stop A3" if [$2 = "start"]; then echo "will be opened" elif [$2 = "stop"]; then echo "will be closed" fi elif [$1 = "B"]; then echo "B1MagneB2 fi elif" if [$2 = "start"] Then echo "will be opened" elif [$2 = "stop"]; then echo "will be closed" fi fi}
Increase execution permissions:
Chmod + x env_switch.sh
Put it in the ~ / .bashrc file so that when each terminal is opened, our custom commands are automatically loaded:
Echo 'source / home/radia/cmd/env_switch.sh' > > ~ / .bashrcsource ~ / .bashrc
You can see that there is only one function in the above script envswitch.sh, and it is not called. This is the key technique in this section, use the source command to import the functions in the script into the current shell, so that the functions in the script can be used like other shell commands, if you have other requirements, you can add functions in the envswitch.sh file, add a function, and you will add a command.
This method is suitable for a series of operations that you do every day, and it is a good choice to sum up into a common command.
In addition, in some test scenarios during the development process, if multi-step operations are required and will be used frequently over a period of time, it is recommended to write them into scripts instead of adding them to commands.
4.3 Let's talk about the bd command
Careful students may have found that, in fact, the bd command we used before is only a small script with more than 50 lines, and we can usually spend time writing some of our own small scripts in use, so that work efficiency will continue to improve.
These are all the contents of this article entitled "what are the skills 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.