Summary of ten Linux command aliases that can improve efficiency

  • 2021-08-12 04:14:35
  • OfStack

Preface

Engineers working in Linux environment will be impressed by the tedious command line of instructions and parameters. Moreover, the terrible thing is not tedious, but the need to type these tedious commands repeatedly.

Under Linux, we have the alias command alias, which can customize those tedious commands as aliases that we can easily remember, which can greatly improve our efficiency.

However, the alias command is only valid for the current terminal. When the terminal is shut down, all the aliases we set are invalid. So if we want these aliases to be permanent, we need to add them to the. bash_profile file.

In this article, Liang Xu will introduce 10 command aliases that are very practical and can improve your work efficiency.

1. Compressed package files, especially tar files, are widely used under Linux, but there are many options for tar command, which is not easy to remember. Therefore, we can define several commonly used options as 1 alias untar, so that when we need to extract tar files, we can directly untar filename.


alias untar='tar -zxvf '

2. When we downloaded a large file, the network was suddenly interrupted. Is it crazy for us to download it again? Don't worry, our wget command has a-c option that supports breakpoint downloads, or we can set it to an alias:


alias wget='wget -c '

3. Sometimes we need to generate a 20-character random number password. We can use openssl command, but the complete command is very long and inconvenient. We can set alias:


alias getpass="openssl rand -base64 20"

4. After downloading a file, we want to verify its checksum value under 1. We can encapsulate this command as 1 alias sha, and then we can verify the checksum value of the file with sha filename.


alias sha='shasum -a 256 '

5. Under normal circumstances, the ping command will be output indefinitely, but it doesn't make much sense. We can use the-c command to limit it to 5 outputs, and then set it to the alias ping. When using it, ping url is enough.


alias ping='ping -c 5'

6. If we want to start an web server anytime, anywhere, we can use this alias:


alias www='python -m SimpleHTTPServer 8000'

7. Network speed testing is often used in work, but Linux does not have its own command available. We can use the third-party tool speedtest-cli. This tool can be downloaded directly from Github, and the usage method is also introduced in detail. We need to use the speedtest-cli command to select the nearest server, and then set the following alias:


alias speed='speedtest-cli --server 2406 --simple'

8. What is your public network IP? If you have a good memory, you can memorize it directly, but what if you have 10 hundred servers? You can also memorize it and join the super brain. In fact, there is a command that can be directly queried, but that command is too abnormal and difficult to remember, so it is decisively set as an alias.


alias ipe='curl ipinfo.io/ip'

9. How do you know your LAN IP? This command is also abnormal, and the alias is set decisively.


alias ipi='ipconfig getifaddr en0'

10. Finally, to clear the screen, we can use ctrl + l shortcut keys, or define clear command shorter, which is more direct and rude to use.


alias c='clear'

These 10 commands you do not need to use completely, because everyone uses Linux in different directions and different work contents. In your field of work, there are a lot of complicated and tedious commands that can be defined as aliases. Welcome to add them in the message area!

Summarize


Related articles: