I executed the following command to create an alias file in CentOS 7.9:
echo 'alias ll="ls -alhF --color=auto"' > /etc/profile.d/alias-ll.sh
Then once I restarted the shell, "type ll" indicated that this alias did not work. I thought this may have been due to another file in /etc/profile.d overwriting the alias, so I renamed the file to "z-alias-ll.sh". Then I restarted shell and this time, "type ll" indicated that the alias had worked successfully.
However when I do the same in Ubuntu 20.04, "type ll" indicates that it does not work. There were some filenames like "Z99-cloud-locale-test.sh" and "Z99-cloudinit-warnings.sh" in /etc/profile.d in Ubuntu, so I tried these:
echo 'alias ll="ls -alhF --color=auto"' > /etc/profile.d/Z99-alias-ll.sh
echo 'alias ll="ls -alhF --color=auto"' > /etc/profile.d/ZZ99-alias-ll.sh
echo 'alias ll="ls -alhF --color=auto"' > /etc/profile.d/Z99-z-alias-ll.sh
echo 'alias ll="ls -alhF --color=auto"' > /etc/profile.d/ZZ99-z-alias-ll.sh
echo 'alias ll="ls -alhF --color=auto"' > /etc/profile.d/Z99Zalias-ll.sh
However, when I restart the terminal, "type ll" still says, "ll is aliased to `ls -alF'".
If I make another alias file:
echo 'alias lltest="ls -alhF --color=auto"' > /etc/profile.d/alias-lltest.sh
Then after I restart the terminal, "type lltest" indicates that this file is being sourced. So, I think the alias files in /etc/profile.d are being sourced, but the alias for "ll" is being overwritten somehwere.
Since I tried prefixing with "ZZ99" etc. I don't think it's an string sorting issue, like with CentOS 7.9, where I had to add the "z-" prefix to the filename to prevent another /etc/profile.d file from taking precedence. However, I am not 100% sure.
What file, script, etc., might be taking precedence over the alias files I created in /etc/profile.d? What takes precedence over /etc/profile.d in Ubuntu, in terms of defining environment variables?
I tried on both Ubuntu 20.04 and Ubuntu 22.10, using fresh Digital Ocean droplets.