10 handy Bash aliases for Linux

Get more efficient by using condensed versions of long Bash commands.
308 readers like this.
bash logo on green background

Opensource.com

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.

User profile image.
Hello! I'm Patrick, and I'm a retired IT Engineer, former IBMer, Writer, Open Source advocate, Gamer, and self-proclaimed super geek. I'm also big into space technologies and exploration, UNIX, the command-line, retro consoles, and retro computers like the Atari 2600, Commodore 64, and the Amiga.

13 Comments

Number 9 is not a valid Linux alias ipconfig is a Windows command, not linux, ifconfig is the Linux command closer to it, and does not have getifaddr command switch. That is if I am not mistaken a c function, part of one of the c libraries for Linux.

Thanks John. That's a valid macOS command. I must have had macOS on my mind when I wrote that part. :-)

In reply to by John Smith (not verified)

Regarding number 10, you can just type ctrl-l to clear the screen. No setup required!

Hi Patrick,

Thank you for sharing these Alias. I am sure I will copy some of them to my own workflow.

Regards.

My most-used aliases are personal ones that would be of little value to someone else. I try not to make single-letter aliases like 'c', since a single letter typo is pretty common for me.

6. should be "alias www='python3 -m http.server'" for python 3.

10. Ctrl+L

RE: 6 how would you load a page at that location after starting the server?

I also use

alias psg='ps auwx | grep '

For #8 you can also use
curl ifconfig.me

alias ll=‘ls -al’

Thanks for sharing all this! Here’s one of mine :D
<3

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.