Under Ubuntu, how can I place a shell alias command that will be global to everyone?

You should put it under:

 /etc/bash.bashrc

to be available to all users.


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.