Change Ubuntu Default ‘ls’ Command Alias…….

Change Default Ubuntu Aliases

By default Ubuntu (plus several others) change the ‘ls’ command to be an alias that colour codes the output. While I’m sure this is great for many people, I don’t like it :o(

I like back background, lime green text, directories indicated with a ‘/’ character at the end, and hidden files to be shown.

To change the default, you need to make the same change in a couple of places…….

Firstly, in your home directory. Edit the hidden file ‘.bashrc’. Find the line that reads alias ls=’ls –color=auto’ and comment it out with a ‘#‘ at the start.

Then add a new line (above or below, does not matter) with the following

ls=’ls -aF’ (in this case, ‘a’ shows all files including hidden ones, ‘F’ indicated a directory by adding a trailing forwardslash ‘/’ after the directory name

This will change your login only. If you also want to change the root ls alias you will need to follow the same steps for the file /root/.bashrc, but you will need to either use sudo with your edit command, or su to root and then edit.

The last place you may wish to edit is the skeleton template file used for all new users. This is located at /etc/skel/.bashrc. Again, eidt the file with the changes above, and all newly added users will recieve a copy of the file and have their ls command alias set to your formatting (if you so wish).

Tags: , , ,

2 Responses to “Change Ubuntu Default ‘ls’ Command Alias…….”

  1. Steffen says:

    Hi,

    This is great. However, if I changed the alias so it displays the long listing (-l), what do I do to get a short listing, in case I need this some time?

    Thanks,

    Steffen

  2. scottb says:

    Just create another alias line without the -l argument, something like

    alias ls=’ls -laF’
    alias lss=’ls -aF’

    So now you have an ‘ls’ which gives a long listing bydefault, and ‘lss’ which does an ‘ls’ short listing

Leave a Reply