How to create a aliases for all the users linux..?

root@puppetclient-ubuntu:/home/azureuser#cat /etc/.bash_aliases
  alias extend_shutdown_15='bash extend_shutdown.sh 15 ; bash /bin/max_timetrack.sh'
  alias extend_shutdown_30='bash extend_shutdown.sh 30 ; bash /bin/max_timetrack.sh'
  alias extend_shutdown_60='bash extend_shutdown.sh 60 ; bash /bin/max_timetrack.sh'

#try to automate and execute the "source /etc/.bash_aliases" through shell script but it is not working means changes are not effecting.

root@puppetclient-ubuntu:/home/azureuser# cat alias.sh
#!/bin/bash
source  ~/.bash_aliases

when I do source /etc/.bash_aliases the alias custom commands are available only for root user and it is not available for all others expect "root" if I do execute one time it should always available for the all users. Please help me to fix.Thanks.


The standard approach in Ubuntu is that aliases are defined and fully controlled by the user, not by the administrator. Yes, some default aliases are defined upon creation of the account, but these definitions are added to the private .bashrc file and thus can be deleted/changed if the user prefers so.

You can customize the default aliases that come with a new account by editing /etc/skel/.bashrc. That file is the default .bashrc file for new accounts.

Control alias definitions as administrator

If, instead, you wish to take control, as administrator, of the aliases of current users, you can define these in a script that you add in /etc/profile.d. All of the scripts present there are executed by /etc/profile, the systemwide profile script executed before the user's private ~/.profile script for logon shells. Prefer this over directly editing /etc/profile, because the latter file is controlled by your package manager and may be overwritten during a future update.

Be aware that some users might not like you if you take such control. Also know that users can negate the aliases you impose to them with unalias commands in their private .bashrc file.