Linux For Cynics One user's experiences with Linux


Linux Aliases in .bashrc

About .bashrc

The ~/.bashrc is a hidden file that lives in your home directory that is loaded every time you access the command line(shell) from your Linux box.

Here, you can provide significant customizations to improve your terminal experience and quickly access things you want to use frequently.

This short guide is about adding aliases to this file to provide you with quick shortcuts to commonly used tools.


An alias in the Linux command line is similar to a short-cut in Windows. It maps a string to one or more shell commands.
This can provide quick access to commonly used tools or allow you to create new tools out of existing Linux commands.

Let's look at an example:

alias e='gedit'

This aliases the string "e" to the command "gedit". So every time I type "e" in the Terminal, that will be mapped to the "gedit" command which will open a text editor. So I could type something like:

$ e some_file.txt

And that would open gedit with the file some_file.txt loaded.

Making Your Own

In the Terminal, open your .bashrc file:

$ gedit ~/.bashrc

Somewhere in this file, after the initial setup, add your aliases. Here are my current aliases, with comments:

# opens a directory in the GUI
alias o='nautilus'
# maps gedit to e
alias e='gedit'
# maps gedit to edit
alias edit='gedit'
# allows me to use grep with the recursive and color flag enabled
# much more powerful!
alias g="grep -rn --color"

Try them out!

In the terminal, try:

$ o .

A new window should open with your current directory displayed.

Now go to some directory like your Project's Sandbox and try out

g SomeText .

Which will recursively search for this text in all your files and display it will coloring.

(Hit Ctrl+c to stop the search prematurely)

Filed under: How to Leave a comment
Comments (0) Trackbacks (0)

No comments yet.

Leave a comment

No trackbacks yet.