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 10 UNIX and Linux techniques to improve efficiency?

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

In this issue, the editor will bring you about the 10 UNIX and Linux skills to improve efficiency, which are rich in content and analyzed and described from a professional point of view. I hope you can get something after reading this article.

If your service is also deployed on a Linux machine, and you spend a lot of time every day searching and manipulating UNIX commands, these techniques will save a lot of time. The following tips are a summary of my years of experience in UNIX, and I have summed up 10 tips for working quickly on UNIX:)

If your service is also deployed on a Linux machine, and you spend a lot of time every day searching and manipulating UNIX commands, these techniques will save a lot of time.

Use! Used to execute the last command

UNIX, how do you take advantage of most of the features provided by Linux and other UNIX operating systems, such as Fedora,Ubuntu,CentOS, etc. I look forward to getting more skills from you to enhance my arsenal, so please share your way of working. Powerful Linux commands and Shell utilities?

This saves me an average of 30% of my time. Usually, you trigger the same UNIX command several times in a few seconds, and then you know that I used the up and down arrows to find the commands and execute them, which took me some time.

After knowing this technique, I just need to remember the name of the command, for example! Ls will execute your last "ls-lrt", and! Vim will open your last file without having to type the complete command.

Using this technique and experiencing it is sure to save time and is also useful on shell other than bash shell (such as csh or ksh), where the up and down arrows usually do not provide you with the previous command.

For example, if you want to open ls-l stocks.txt,stocks.txt, you can use the vim editor to take advantage of vi! $(last parameter)

Use "CRTL + R" to repeat the last matching command

If you remember that the last command was executed at some point, and you only want to find commands with the same parameters and execute them, it's best. This is a skill you need to remember.

Just press "CRTL + R" and enter the word you entered in the previous command, and UNIX will find the command for you and press Enter.

If you can execute commands, the above techniques will save a lot of time and a high percentage of repetition. For me, I saved nearly 50-60% of my time. Let me know how it works more efficiently.

This is a very useful technique, and it even finds its place in one of the Julia Evans charts, as shown below:

Insert a picture description here

Use! Used to execute the last command

This is an extension of the previous technique to execute the last command you executed. Because it involves only two keystrokes, and this is true for the same key, it is very fast.

This also applies to shell where the up and down arrows do not work like K shell and C shell. This is useful if you stop or start a server or Java application in order to redebug ging.

Insert a picture description here

Use the history command to get some of the most commonly used UNIX commands

Well, this is the first trick I learned when I started using UNIX: this is the most useful command in UNIX and Shell scripts.

In most cases, there are certain commands, such as start,stop, checking log files, making a build, or publishing.

These are the commands you often need to execute, and if you don't remember the previous command, you don't need to worry, just the history | grep "keyword", which you can get from the history on the Linux machine.

There are some environment variables, such as HISTSIZE, which define how many commands the UNIX history can store.

Use regular expressions in grep and find

The grep and find are two of the best tools available to us by UNIX. Almost everyone needs to search for something in UNIX, such as files, directories, and certain words in files (such as ERROR or Exception). If you know how to use grep and use regular expressions to find, you will save a lot of time by typing commands.

For example, by knowing egrep, you can trigger egrep "ERROR | Exception" * .xml instead of triggering two grep commands to find ERROR and Exception, respectively.

Use pipes instead of triggering two commands

As shown in this little trick above, I think everyone knows:)

Use aliases and define them in the bash configuration file or bashrc file

Have you ever seen some strange commands working on someone's computer instead of yours, which may be an alias set in his .bashrc or .profile file?

This is always set for commonly used commands. .bashrc and .profile files are used in many ways, but one of the most important uses is to set aliases, such as "l.". Find all hidden files. "ls" includes all useful options, such as-lrtH to display all relevant information.

Use push, popd, cd- to move through the directory

In my experience, it takes almost 50% of the time to navigate through UNIX shell, and if you write directory paths from time to time, you forget to work quickly. Therefore, instead of using the full name, use all the prompts above and take full advantage of the PUSHD,POPD,CD- and cd~ commands. CD- is best if you switch between two directory locations in UNIX.

Minimize keystroke or improve typing speed

I think you know, the fewer times you type, the faster you will work with the last command you typed, please use the tab in bash, kill let UNIX bash shell finish your command, if Ctrl + R the last command you type is long, you only want to change a few lines.

Continue to learn the new Linux command

Trying to learn more commands and their options and using it will reduce the time it takes to think about specific tasks and use ctrl + z and fg and bg to pause the process.

If you are viewing multiple files or log files, you only need to save nearly 10% of your time, so instead of immediately executing the vim command and then pressing Ctrl + Z to suspend it, execute fg 1 or fg 2 to put it in the foreground.

This is another comic book to remember some of the more useful bash tips:

These are the 10 UNIX and Linux techniques to improve efficiency shared by the editor. If you happen to have similar doubts, you might as well 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.

Share To

Development

Wechat

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

12
Report