Some Useful Bash Aliases

In this post, I’d like to talk about bash aliases or more specifically how to create them and a few more useful ones. Aliases are very useful for shortening long, frequently used, mistyped or hard to remember commands.

In order to view any current aliases you may have setup on your computer, you issue the command:


Which gives you an output similar to this:



There are two main ways to add aliases. The first is to use the command alias. The below example creates an alias called update which when called, updates the repositories on the system.

alias update='sudo apt-get update'

To remove the alias you just created, replace alias with unalias and drop the command leaving only the alias name:

unalias update

The second method is to add the alias to the .bashrc file. To do so, open the file for editing:

vi ~/.bashrc

and add your aliases into the file:

bashrc aliases definition

bashrc aliases definition

Note that if you use this method (via .bashrc), you will need to reload your bash terminal by issuing the following command before it will work (or simply close and reopen the terminal)

exec bash

To remove this alias all you have to do is delete or comment out the alias you just created and reload the terminal again.

Now that you know how to create and remove aliases, I’ll list some that I find helpful.

Backing up (using a custom rsync command):

backup='sudo -azv --delete-before --exclude-from=/home/seawolf167/exclude-list / /media/backup_directory'

SSH into your server:

connect='ssh -l seawolf167 -p 44000'

Update your repositories:

update='sudo apt-get update'

Upgrade your system:

upgrade='sudo apt-get upgrade'

Update and upgrade:

uu='sudo apt-get update && sudo apt-get upgrade'

Install a program:

install='sudo apt-get install'

Change to the parent directory:

..='cd ../'
...='cd ../../'
....='cd ../../../'
.....='cd ../../../../'

Run a script:



sd='sudo shutdown -h now'


rb='sudo reboot'

And so on and so forth until you have so many aliases you forget their base commands 😛

Tagged , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published.

Protected by WP Anti Spam