I would like to have

alias ll="ls -l"

to be system wide.

How is that done on Ubuntu?

| improve this question | | | | |

Add it in to /etc/bashrc. This will (or should) get called on login by every user who uses bash.

| improve this answer | | | | |
  • 2
    My machine (Ubuntu 12) doesn't have /etc/bashrc or any references to it in /etc/profile, ~/.bashrc or elsewhere. The place I found that was best to do this, decoupled from the system's files and thus better for maintaining customizations with something like Puppet, is to place a file in /etc/profile.d/ – Spanky Dec 4 '13 at 18:11
  • I believe the correct location is actually /etc/bash.bashrc FWIW – Paul Carroll Jan 20 at 4:04
# echo "alias ll='ls -l'" >> /etc/bash.bashrc

and make sure that this file is executed whenever an user enters a shell by adding the following in ~/.bashrc:

# Source global definitions
if [ -f /etc/bash.bashrc ]; then
    . /etc/bash.bashrc
| improve this answer | | | | |
  • This answer was helpful. In Ubuntu 14.04, when I opened my .bashrc file, near the end, there's a pre-created section similar to the if [...] @quanta mentions, except is uses .bash_aliases. All I had to do is echo the alias into echo "alias ll-'ls -l'" >> ~/.bash_aliases since .bashrc already had something setup in this environment. And I closed/re-opened putty. – jmbertucci Jan 4 '15 at 19:50

If your user's $HOME/.bashrc contains the usual

if [ -f /etc/bashrc ]; then
        . /etc/bashrc

Then put it in /etc/bashrc. If it doesn't then put it in /etc/profile from where it will at least be read for login shells.

| improve this answer | | | | |

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