In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, the editor will give you 10 suggestions on how to work quickly on or Linux terminals. The article is rich in content and analyzed and described from a professional point of view. I hope you can get something after reading this article.
Have you ever been surprised to see someone working very fast in Unix/ Linux, crackling on the keyboard, starting commands quickly, and executing commands quickly?
In this article, I share some Unix/ Linux command practices that I follow to work quickly and efficiently in Linux.
All of our services run on Linux servers, so it's important for us to work efficiently and quickly on Linux terminals, and these are the productivity tips I learned in Linux.
If your server also resides on a Linux machine, and your two-day work involves a lot of searching and operations around UNIX commands, these techniques will save you a lot of time.
Use "!" Used to execute the last command
This saves me an average of 30% of my time. Usually, you trigger the same Unix command multiple times in a few seconds, and before I know this trick, I use the up and down arrows to find my commands and execute them, which takes me a lot of time. However, after knowing this trick, I just need to remember the command name, for example! ls will execute the last "ls-lrt" and! vim will open your last file without entering the full command. Using this technique is sure to save a lot of time, and it's also useful on shell, not just bash shell (such as csh or ksh), where the up and down arrows usually don't give you previous commands.
For example, after executing ls-l stocks.txt, if you want to open stocks.txt, you can use the VIM editor as vi! $(last parameter).
Use "!!" Used to execute the last command
This is an extension of the previous technique to execute the last command you executed. Because it requires only two keystrokes, and two keystrokes for the same key, it is very fast.
This also applies to shell where the up and down arrows are different from k shell and c shell. This is very useful and suitable for scenarios where you are stopping or starting a server or Java application debugging frequently.
Use "ctrl+r" to repeat the last matching command
"ctrl+r" is a very effective command if you remember the command you executed earlier and only want to find the command with the same parameters and execute it. It can match characters anywhere in the command and display the most recent command.
Just press "crtl+r" and type the word from the previous command, and Unix will find the command for you, and then press Enter.
If you execute commands frequently and have a high percentage of repetition, all three techniques can save a lot of time.
Use the history command to get some of the most commonly used unix commands
Well, this is the first skill I learned when I started using Unix. This is the most useful command in UNIX and shell scripting.
In most cases, there is a specific command, such as starting, stopping, checking log files, generating or executing releases, and so on.
These are commands that you often need to execute, and if you don't remember the exact command, don't worry, just execute history grep "keyword" to get it from the history of the Linux machine.
There are some specific environment variables that set the unix history of up to how many commands are stored. It is recommended that you set them as large as possible so that you can easily find previous executed commands and avoid frequently searching the Internet to find out how to use these commands.
Using regular expressions in grep and find
Grep and find are two of the best tools that Unix provides to us. Almost everyone needs to search for something in Unix, such as files, directories, certain words in files (such as errors or exceptions), and if you know how to use grep and use regular expressions to find it, you can save a lot of time by typing fewer commands.
For example, by learning about egrep, you can start egrep "error exception" * .xml instead of launching two grep commands to find errors and exceptions.
Use the pipe instead of issuing two commands
As shown in the picture above, I think everyone knows this good tip.
If you don't know, it's best to start with a good Linux course, such as the basics of the Linux command line, because you may not know some other basics either.
From my personal experience, it is better to take a good course than to find basic information in bits and pieces.
Also, if you don't mind learning from free resources, you can also check out a list of five free Linux courses I offer to developers.
Use aliases and define them in a bash profile or bashrc file
Have you seen some strange commands running on someone's machine instead of yours, which may be the alias he set up in the .bashrc or .profile file?
This is always set for commonly used commands. There are many uses for .bashrc and .profile files, but one of the most important uses is to set aliases, such as "l", which can find all hidden files. "ls" includes all useful options, such as-lrth, to display all relevant information.
Use pushd, popd, cd-, ~ to move through the directory
In my experience, navigating (switching file directories) in Unix shell consumes almost 50% of our time. If you want to write directory paths from time to time, forget to work quickly.
Therefore, instead of typing the full name, use all the prompts above and take full advantage of the pushd, popd, cd-, and cd~ commands. If you switch between two directory locations in UNIX, cd- is the best choice.
Reduce the number of keystrokes or increase typing speed
The less you type, the faster you will work.
To use the last command you typed, use tab in bash so that unix bash shell can complete the command.
If the last command you type is long and you only want to change a few lines, use ctrl+r.
Keep learning new Linux commands
Trying to learn more commands and their options and using it will reduce the time it takes to think about specific tasks and suspend processes using ctrl+z, fg, and bg.
If you view multiple files or log files, you can save nearly 10% of your time, so instead of executing the VIM command every once in a while, simply press ctrl+z to suspend it, and then press fg 1 or fg 2 to put it in the foreground.
These are the 10 suggestions shared by the editor for you to work quickly on or Linux terminals. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are 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.