Skip to content

Making life easier with bash aliases

Updated: at 08:11 AM

For me one of the beautiful parts of using Linux is being able to script everything I need. I have scripts that change my Razer Tartarus Profiles, run Hudkit, handle browser sounds, and so much more.

Having scripts is great, but being able to get the script to run with a set of commands that I create? chef’s kiss

The following is a quick and dirty how to. No explanations really, but if you need help just reach out to me on Mastodon.

Using bash_aliases

  1. Edit bash_aliases: vi ~/.bash_aliases (yes, I am a vi user)
  2. Add alias: alias aliasname="command user@location"
  3. Refresh bash: source ~/.bash_rc

Important Note

The above works only if .bashrc includes the following code:

if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi

Examples

Connect to a server through ssh with a specific user using the command pumpkin

alias pumpkin="ssh [email protected]"
Note: SSH Options. You have them.

There are circumstances where I would not recommend using a bash aliase for SSH. Check out my article on SSH Config to see if that option works better for your use case.

Run updates with the command yiss

alias yiss="sudo apt update && sudo apt upgrade"

Quickly view available aliases because you know you’ll forget

cat ~/.bash_aliases