28

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?

  • 2
    Whats the output of grep -n 'NeverGonnaGiveYouUp' ~/.profile ~/.bashrc /etc/bash.bashrc /etc/profile ? There are some other files to look at too depending on your shell and distro..but this should give us a start.. – heemayl Feb 8 '16 at 4:49
  • 5
    That sounds like that rick roll kernel module LOL – moonbutt74 Feb 8 '16 at 5:11
24

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.

16

unalias command turned off alias for the duration of the current login session. the alias is not removed by unalias command from the .bashrc file, when the user logs in again, that alias is again in effect.

.bashrc is a hidden file, You can check the list of alias by typing:

$ alias

Check shell configuration file ~/.bashrc and you can remove required alias permanently:

 vi ~/.bashrc

To find Alias:

  $ type --all ls

Remove an alias:

unalias gs

More at Manual

Note: unalias -a will remove all alias definitions from the current shell execution environment.

-1

For Ubuntu 16.04 LTS you can use following command

cat /dev/null > ~/.bash_aliases
  • That will remove anything defined in ~/.bash_aliases, not just the ls alias (which might not even be defined there anyway). – Stephen Kitt Apr 23 '18 at 8:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.