70

10 handy Bash aliases for Linux

 5 years ago
source link: https://www.tuicool.com/articles/hit/JriUnqz
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How many times have you repeatedly typed out a long command on the command line and wished there was a way to save it for later? This is where Bash aliases come in handy. They allow you to condense long, cryptic commands down to something easy to remember and use. Need some examples to get you started? No problem!

To use a Bash alias you've created, you need to add it to your .bash_profile file, which is located in your home folder. Note that this file is hidden and accessible only from the command line. The easiest way to work with this file is to use something like Vi or Nano.

10 handy Bash aliases

  1. How many times have you needed to unpack a .tar file and couldn't remember the exact arguments needed? Aliases to the rescue! Just add the following to your .bash_profile file and then use untar FileName to unpack any .tar file.
alias untar='tar -zxvf '
  1. Want to download something but be able to resume if something goes wrong?
alias wget='wget -c '
  1. Need to generate a random, 20-character password for a new online account? No problem.
alias getpass="openssl rand -base64 20"
  1. Downloaded a file and need to test the checksum? We've got that covered too.
alias sha='shasum -a 256 '
  1. A normal ping will go on forever. We don't want that. Instead, let's limit that to just five pings.
alias ping='ping -c 5'
  1. Start a web server in any folder you'd like.
alias www='python -m SimpleHTTPServer 8000'
  1. Want to know how fast your network is? Just download Speedtest-cli and use this alias. You can choose a server closer to your location by using the speedtest-cli --list command.
alias speed='speedtest-cli --server 2406 --simple'
  1. How many times have you needed to know your external IP address and had no idea how to get that info? Yeah, me too.
alias ipe='curl ipinfo.io/ip'
  1. Need to know your local IP address?
alias ipi='ipconfig getifaddr en0'
  1. Finally, let's clear the screen.
alias c='clear'

As you can see, Bash aliases are a super-easy way to simplify your life on the command line. Want more info? I recommend a quick Google search for "Bash aliases" or a trip to GitHub.

About the author

Patrick H. Mullins

Patrick is a veteran Information Technology professional, IBMer, and Senior Cloud Specialist at The Hartford. His professional interests include Web Development, Cybersecurity, ARM-based single-board microcomputers, space technologies and exploration, and infrastructure hyper-connectivity (IoT). Patrick graduated from Baker College with a B.S. in Computer Science and from the University of Illinois at Urbana-Champaign with a certificate in UNIX Systems Engineering. He is also a member of the...

More about me


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK