You are not logged in.
Pages: 1
I am trying to set a global alias for all users. I thought to define this in either /etc/profile or better some file in /etc/profile.d/
I deliberately put some simple export before the alias definition just to be sure the file is picked up after reboot.
/etc/profile.d/ls-grep.sh
export FOO="bar"
alias abcd='ls --color=auto'
After reboot, FOO is defined but alias abcd is not defined. How can this not work?
Last edited by mico (2016-10-18 18:50:40)
Offline
Those files are only read by login shells. The exported variable is inherited by child processes, but the alias is not. If, for example, you or a DM only uses a login shell to start an X server and you run an interactive shell in a terminal emulator, that shell does not read /etc/profile(.d/*) but it will inherit $FOO.
You can add aliases in /etc/skel/.bashrc to enable them for new users. If you want to add aliases later for existing users, you can loop over the users and append to their ~/.bashrc or make them source some global list of aliases in their ~/.bashrc. I'm not aware of any standard (global) file location that is automatically sourced.
Offline
I'm not aware of any standard (global) file location that is automatically sourced.
https://wiki.archlinux.org/index.php/Ba … tion_files
I put an alias in /etc/bash.bashrc and it is available to all my users (in an interactive shell.)
Offline
Cheers, that explains it.
I will probably use /etc/bash.bashrc.
Offline
Define your alias in /etc/bash.bashrc
alias foo='bar'
Go to EOF of /etc/profile and add:
source /etc/bash.bashrc
Then, back at the prompt, simply:
source /etc/bash.bashrc
EDIT: My bad, it seems that /etc/profile already sources /etc/bash.bashrc.
Although, in my defense, I have seen versions of /etc/profile that did not.
Last edited by S3NTYN3L (2016-10-18 19:21:37)
Offline
Pages: 1