Under Ubuntu 9.10, where can I place an alias command that will be valid to all users, root or otherwise, and that will work with a shell under GNOME as well as an ssh session and plain console login ?

For example, I love the ll command, which is not defined by default under Ubuntu, but is under openSuSE. I can manually enter:

alias "ll=ls -als"

but it will only be valid for the current shell. I want this to be valid for all users, all the time, remote or local connection.

Which file should I edit?


You should put it under:


to be available to all users.

  • Yes. However, by titself under Ubuntu, this is not enough. I had to add the line "source /etc/bash.bashrc" at the end of th e/etc/profile file. – jfmessier Feb 6 '10 at 2:15
  • I didn't need to - it works for me – Jon Feb 6 '10 at 2:20

Actually, I found that the answer, at least for me, is a combination of two previous answers. I found that the following was working for me:

The file /etc/profile is indeed executed, but the alias commands there are not working. I understand that the alias command there is only valid while the shell process is executed. Looking at the file /etc/bash.bashrc, I read at the top of the file that the file has to be "sourced" from /etc/profile.

So I added the alias command that I wanted in /etc/bash.bashrc first. like:

 alias "ll=ls -als"

Then I appended the source command at the end of /etc/profile:

 source /etc/bash.bashrc

It seemed to be working fine in both a shell locally launched and one from an SSH connection.


Try the /etc/profile file.

This is intended for system-wide initialisation of the Bourne shell and compatible shells.

  • I tryed the alias command by itself there, and it was not running. As I was opening a new shell, the command was not available. However, by adding "source /etc/bash.bashrc" and the actual alias command at the end of that file, it was then working all fine. – jfmessier Feb 6 '10 at 2:17

As stated on the top of the file /etc/bash.bashrc:

 # System-wide .bashrc file for interactive bash(1) shells.
 # To enable the settings / commands in this file for login shells as well,
 # this file has to be sourced in /etc/profile.

So, both Jon and jfmessier are correct. Jon probably had /etc/bash.bashrc already sourced in /etc/profile, which seems to be the default case.

I would recommend to insert the alias commands in /etc/bash.bashrc and try to run them first, both with your normal user and with root. If they run as expected, you don’t need to source the file on profile. If they don’t, then source them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.