What are your favourite aliases?

The idea of this thread is to post your favourite aliases from your .bashrc.

Section 1 – What is an alias?

If you already know what an alias is, feel free to skip this section and check out section 2 containing my aliases, or just go ahead and post some of your favourite aliases.

But if you don’t know what aliases are, I will explain. Please read on…..

Aliases allow you to create convenient shortcuts for common commands – to save you some typing, and/or to prevent you having to remember a lot of different commands/switches etc.

So if there are any really long commands that you use often. Instead of having to type the whole command, you can open up your .bashrc file and set up an alias instead. Or if it is just something you will be using in the current terminal session, you can just set up a temporary alias using the built-in alias command.

Whether you set a temporary alias for the current terminal session, or set a permanent one in your .bashrc file. The syntax to set up an alias is:

alias alias_name='/your/commands/and -options -go -here'

As a practical example:

is a command that everybody uses in the terminal and there are lots of different options/switches that can be passed to ls that will allow you to see files listed in different ways. If you always want the output to appear in a certain way, you can set your preferences by setting up an alias for ls.

So if you always want ls to show all files, in the long-list format, with indicators at the end of file-names ( e.g. / for directories, * for executables), with human-readable file-sizes and you always want to see directories listed first; Then you could set the following alias:

alias ls='ls -alFh --group-directories-first'

Now whenever you type ls, the alias will be invoked and you will see the output in your desired format.

To invoke the original ls without using your alias, you can bypass the alias by typing:


That will ignore any aliases for ls and will directly run the ls command in /usr/bin/ instead.

Alternatively, if an alias is no longer required you can use the unalias command to remove it from the current terminal session, or you could remove it from your .bashrc file if it is a permanent one.

The syntax for the unalias command is:

unalias name_of_alias_to_remove

Section 2 – My favourite aliases:

OK, now you know what aliases are – here are a few of my favourites:

Re-read/Re-apply .bashrc

This is something I use a lot. Whenever I make changes to my .bashrc, I often want to apply them to any terminals I have open. So I have set-up the following alias:

alias reinit='. ~/.bashrc'

After making changes to my .bashrc, I can use the reinit alias to quickly apply the changes to the current terminal.

Remove backup files

As a vim user, I find that I often end up accumulating a lot of backup files. So I have set up a couple of aliases which I periodically use to remove unwanted backup files.

alias rmb='find ./ -type f -iname "*~" -delete &'alias rmib='find ./ -type f -iname "*~" -exec rm -i {} ;'

rmb will recursively find and delete all files with names that end with the ~ character. Because of the & at the end of the command, find is ran in the background. That way I can continue working in the terminal while the find command finds and removes backup files.

rmib will recursively find all files with names that end with the ~ character and will interactively ask whether to remove each file it finds. Because this is an interactive command, I don’t run it in the background.

Listen to internet radio-stations in the terminal

From looking at my avatar-pic, or reading my profile here you’ve probably guessed that I’m quite heavily into music…. And heavy music at that.

When working in the terminal I like to be able to listen to a bit of music. And I don’t always want to interrupt my flow by firing up a GUI media player. So I’ve set up aliases for two of my favourite internet radio stations – Hard Rock Hell Radio and Neue Regel Radio:

alias HRH='cvlc http://andromeda.shoutca.st:9254 &> /dev/null &'alias NRR='cvlc &> /dev/null &'

With these aliases in place, I can listen to my favourite stations by issuing the HRH or NRR command in the terminal.

On execution of one of these aliases:

cvlc is started in the background and starts streaming the station I want to listen to.

All text output (error messages etc) is redirected to /dev/null using the &> redirection operator – so the running process never interrupts what I am doing.

When I’m finished listening, I use the jobs command to get the PID for vlc:

jobs -l

And then I use the kill command to kill it:

kill -15 {PID}

Note: the use of signal 15 (SIGTERM), which politely asks the process to end, rather than signal 9 (SIGKILL) – which will forcefully kill the process. See here for more info…

At some point, I’ll probably get around to setting up an alias for that too!

Anywhoo, those are a few of my favourite aliases. What are yours?

Leave a Reply

Your email address will not be published.