Home > Bash, Ubuntu > Create Aliases in Ubuntu

Create Aliases in Ubuntu

How to Create an Alias in Ubuntu

If you run the same commands in Linux (or Ubuntu) all the time, you can add what is called an “alias” to your user account. For example, I regularly type:

ls -alh

So I setup an alias so that I can just type la. (also, see my Top 10 Aliases list) To do this, simply edit your “profile”. Bash is the program that you typically use when you are in a command shell, so it may be called your “bash profile”. Your profile is in your Home folder and stores all of your preferences. Just edit the “.profile” or the “.bash_profile” if it exists.

cd ~
pico edit .profile

Add the following code to the bottom:

alias la='ls -alh'

Now when you are typing at the command prompt, you just type la and it acts like you typed ls -alh. Pretty handy.

  1. ander
    September 16th, 2010 at 11:16 | #1

    I tried this with Linux Mint 9, but it had no effect.

  2. Hailon
    March 30th, 2011 at 09:26 | #2

    @ander
    Try .bashrc

  3. hippie
    April 25th, 2011 at 21:49 | #3

    @ander you did it wrong then. instead of pico, use nano. Pico is not installed by default.

  4. May 17th, 2011 at 15:14 | #4

    Nice article–I could’t remember the syntax for this command, so this we helpful!

    Just a quick tip: You can also type the “alias la=”ls -alh” directly into the terminal to create an alias. For example, entering the following command (minus the “user:~$” part) would allow me to enter “la” in place of “ls -alh”:
    user:~$ alias la=”ls -alh”

  5. grimfiend
    July 13th, 2011 at 13:05 | #5

    I want to set up an alias that uses multiple commands. Can this be done? If so, how does one go about doing it using the alias command only?

  6. grimfiend
    July 13th, 2011 at 13:09 | #6

    Disregard, just found my answer….thx

  1. No trackbacks yet.