Why can I still use the alias defined in the /etc/profile.d directory after deleting all the files in it?

Hi:

openSUSE provides many aliases by default, among which “l” is set to the alias “ls -alF’”. As far as I know, these aliases are defined in the /etc/profile.d directory.

type l
l is aliased to `ls -alF'

But when I delete all the files in the /etc/profile.d directory and log in to the account again, I can still use the originally set alias. Why is this?

There are no relevant alias settings in my .bashrc and profile files.

Thanks

You current shell has cached this information.

Have you tried to logout, then login again. Or maybe reboot and then login again.

My advice: it’s best to not remove files from “/etc/profile.d”. If you remove them, they will come back at some future update.

Better solution would be to add a line to your “.bashrc”

unalias -a

That will remove all aliases on shell startup.

1 Like

What prevents you from checking?

Hi:
Thanks for your reply.
Using your method did solve the problem.

I found that Leap and tumbleweed seem to have different configurations.

Tumbleweed also has a profile.d directory in the /usr/etc/ directory, which contains files for alias settings. This is why I can still use aliases even after deleting the information in the /etc/profile.d directory.

unalias’ing helps here as said above.

However, the question really would more be ‘why’.

I can understand that an alias of rm to be rm -i instead (hello redhat) can be annoying but…

So really the question is why. (curious here)

And I am also curious why the solution is searched by changing system wide settings that will work on all users (changing in /etc/ and not just on the environment of the user involved (as offered by @nrickert ).

Indeed, I asked a somewhat boring question

you are referring to a problem. (initial post)

Just wanted to know what that problem is, nothing more, nothing less.

Presumably, he does not like the aliases and wants to not have them. I sympathize. I also don’t like the default aliases.

I can understand rm = rm -i is something I would have go.
So I unalias them in the .bashrc when I am at RH machines.
I’m not a baby. I also copy PS1 of root there too. However,

the inital question talks about ‘l’ being an alias. So what about just not executing ‘l’ the first place…

So I am wondering what his take on this is. And like mentioned, do in your profile(s)…

I started using unix before there was a linux. So I am used to the non-alias versions of the commands.

Additionally, the typical linux aliases have the annoying habit of using various colors for the output. And for those of us who have atypical color vision, that can make it hard to read.

Assuming you’re talking about the bash shell, one way to check where is that alias defined/stored,

PS4='+$BASH_SOURCE:' bash -xilc '' 2>&1 | grep 'ls -alF'

Or just grep for the string alias to see all. It may or may not work on some cases ymmv.

1 Like

Hi
Since I just recently joined openSUSE, the distributions I used before usually placed the alias settings in .bashrc, so just changing .bashrc can get the desired results.
However, since the alias of openSUSE is stored in /etc/profile.d, I wanted to move the files in this directory to another place first, but I didn’t expect that the alias was still in effect, and that’s why I had this problem.
But as discussed above, it seems to be a bit boring question.

This user has

henk@boven:~> tail -2 .bashrc

test -s ~/.alias && . ~/.alias || true
henk@boven:~> 

This is not of my invention, but it was there when the user was created (long, long time ago, thus I am not sure if user creation now still provides the same).

This suggests that a good way to manage your aliases is creating the file ~/.alias and set your alias preferences (maybe unalias -a ) there.

This is of course for the user to set his/her preferences.

I am not a fan of some of the methods above where the system manager (root) changes things in the systems configuration, thus setting (changing) things for all users.
There may of course be a reason to to something to affect all users, but I doubt that was the argument here. My interpretation from the original post and some of he others is that people are only talking about their personal preferences.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.