Shell – How to permanently remove an Alias from the Shell

aliasshellterminal

When I was not near my computer some guy got it and set an Alias for ls in my root folder. He set it to 'yes NeverGonnaGiveYouUp'. So now when im in my root folder and type ls I get an infinite loop of NeverGonnaGiveYouUp. It's driving me nuts and I don't know how to get rid of it.

I've already tried unalias and unalias -a but those just remove it temporarily. Once I close the shell and reopen it it comes back. How do I get rid of this crap?

Best Answer

If unalias removes the issue (even temporarily) we have confirmation it is an alias. It could be "brute forced" out by adding an unalias ls in ~/.bashrc.

echo "unalias ls" >> ~/.bashrc

That will get excuted every time bashrc is read and will remove the alias.
That will buy you some peace but will not resolve the actual issue that some file is still containing code to re-start the alias. You need to find which file contains the problem.

If using bash:

grep "NeverGonnaGiveYouUp" /etc/profile /etc/bash.bashrc \
      ~/.bashrc ~/.bash_profile ~/.profile \
      /root/.bashrc /root/.bash_profile /root/.profile

That's a good list of possible files that got the definition. If nothing shows up in that search, or you use some other shell, let us know to further help.

Related Question