I am looking for a simple way to create a permanent alias for all users. So ~/.bashrc
or ~/.bash_profile
is not an option.
Hasn't anybody created a program for this? I think it should be a very common need. If not, I can always create a custom Bash script, but I need to know if there is a equivalent of .bash_profile for all users.
In my case, I am using Mac OS X v10.9 (Mavericks) and Ubuntu 12.04 (Precise Pangolin), but I would like a method that works on major Unix systems.
UPDATE: I was wondering about a program which automatically allows the users to manage a list of permanent of aliases directly from the command-line without having to edit files. It would have options for setting for all users, target users, interative/login shell, etc.
UPDATE 2: Reply to answer of @jimmij
$ su -m
Password:
# cat /etc/profile
alias test343="echo working"
# cat /etc/bash.bashrc
alias test727="echo working"
# test727
bash: test727: command not found
# test343
bash: test343: command not found
Best Answer
Please have a look at
bash
manual:/etc/profile
The systemwide initialization file, executed for interactive login shells
/etc/bash.bashrc
The systemwide initialization file, executed for interactive, non-login shells.
~/.bash_profile
The personal initialization file, executed for interactive login shells
~/.bashrc
The individual per-interactive-shell startup file
~/.bash_logout
The individual login shell cleanup file, executed when a login shell exits
So you need to put your aliases in
/etc/profile
or/etc/bash.bashrc
in order to make them available for all users.