DEV Community

Cover image for Ubuntu aliases by a beginner for beginners
Kurtiss Frost
Kurtiss Frost

Posted on

Ubuntu aliases by a beginner for beginners

Hello and welcome to my guide to creating aliases on Ubuntu. You can also find this on my GitHub. Before we begin, let me just say that I am no linux guru. There is probably another way to do this that is better but, this was how I learned how to do it and I want to share my process. For all examples listed below, I am using Ubuntu 22.04 LTS. Now, let's jump right on in!


Ok, so first off, you need to find a command that you either want to change because of the length, or because you want to map it to a different input for either ease of memory or for style. For example, the command to put a linux machine to sleep "systemctl suspend" That's kind of a length command. So let's change it to something both flashy and easier to remember like "goodnight"


  1. Open your terminal up by either going to "show applications" or by using the keyboard shortcut ctrl+t.

  2. In the terminal, type the following

    nano .bash_aliases

  3. In your newly created file, type

    alias goodnight='systemctl suspend'

  4. For convenience. we should also add the following aliases (it will make sense later)

    alias SA='source .bash_aliases'


    alias aliases='nano .bash_aliases'

  5. Next, hit ctrl+x and then press Y. Once you do this, you can press enter and it will take you back to the terminal.

Unfortunately you can't just use your new shiny commands yet. You need to type

source .bash_aliases

Remember earlier when I said to add the alias CA? This is why. Unless you spice your aliases, the terminal won't recognize them. Now that we have that alias, instead of typing the nano command again, we can just type the word alias in the terminal to add more "aliases". Typing the word "goodnight" will suspend our system and the command SA will source our changes.


Other Examples:

alias update='sudo apt update'
alias upgrade='sudo apt upgrade'
alias dejavi='echo dejavu'


Using this method, you are really only limited by your imagination. You can make the aliases silly, serious, or a combination of the two.

git - the code

Hopefully this guide has been helpful and you can create your own unique and interesting aliases. I definitely would love to take a crack at writing more tutorials and how to guides but, first I think I need to work on my skills a little bit more. But this was a fun little project for me to test the waters and see what I could come up with. Thank you so much for reading and have a wonderful day!

signature

Top comments (0)