How To Make Bash Aliases To Shorten Commands On Ubuntu? - Fosslicious

Wednesday, January 16, 2019

How To Make Bash Aliases To Shorten Commands On Ubuntu?

Bash (Bourne Again Shell), is one of the programs that are included in the most widely used GNU Project. One of the things I use from bash is Aliases.

Creating an Aliases in bash is quite easy, and I use this to shorten the long commands on Ubuntu.

How to make Bash Aliases On Ubuntu?

1. Please find the .bashrc file in the home/your_username directory (use ctrl + h to view hidden files).

2. Open the .bashrc and look for the following code:
if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

Make sure that the code is not commented(#).
3. Next, create a file with the name .bash_aliases.
4. Open the .bash_aliases file and write the alias command according to your needs.

The example of the aliases command that I made for an update on Ubuntu is below!
alias fossup='sudo apt-get update'

Every time you make an aliases must start with an alias command, followed by the name of the desired command. After that, please try typing the fossup command (a command to shorten the default update command) on the terminal.

If successful, the terminal will ask for a password and update the package.
How To Make Bash Aliases To Shorten Commands On Ubuntu

Making aliases should be used according to your own needs to facilitate your work. May be useful.