1

I accidentally linked my "su" command to Sublime Text binary (that's what you get when you trust hitting tab without looking...) Now, "su" just opens a SublimeTExt session. Does anybody know how can I revert to the previous version and point "su" to what it is supposed to be pointing at? Thank you!

EDIT: the command that was accidentaly issued was

sudo ln -s /opt/Sublime\ Text\ 2/sublime_text /usr/bin/su

3 Answers3

1

Original su is in /bin/su, so just delete your link:

sudo rm /usr/bin/su

Check which su if it's back to /bin/su

There a priority in executable paths, see:

echo $PATH

/usr/bin comes before /bin, So your link will be executed first. But to learn create that link again and run which su you will get /usr/bin/su.

Well, all $PATH can hold executable itself or its link. So most of those paths hold a mixture, give ls -l /usr/bin a try (I cut long results) :

total 925272
-rwxr-xr-x 1 root   root       39552 Dec 18 14:36 [
lrwxrwxrwx 1 root   root           8 Dec 21 15:14 2to3 -> 2to3-2.7
-rwxr-xr-x 1 root   root          96 Jan 12 10:12 2to3-2.7
-rwxr-xr-x 1 root   root          96 Jan 27 17:21 2to3-3.3
-rwxr-xr-x 1 root   root          96 Jan 27 17:23 2to3-3.4
-rwxr-xr-x 1 root   root        5655 Jan  7 12:12 404main
-rwxr-xr-x 1 root   root       10320 Feb  7  2013 411toppm
-rwxr-xr-x 1 root   root          39 Feb 17  2012 7z
-rwxr-xr-x 1 root   root          40 Feb 17  2012 7za
-rwxr-xr-x 1 root   root          40 Feb 17  2012 7zr
-rwxr-xr-x 1 root   root      106584 Jan 15 06:49 a2p
lrwxrwxrwx 1 root   root          52 Jan 25 00:22 a2ping -> ../share/texlive/texmf-dist/scripts/a2ping/a2ping.pl
-rwxr-xr-x 1 root   root         883 Apr 30  2007 a5booklet
lrwxrwxrwx 1 root   root          54 Jan 25 00:22 a5toa4 -> ../share/texlive/texmf-dist/scripts/pfarrei/a5toa4.tlu
-rwxr-xr-x 1 root   root       10328 Apr 28  2009 aa3d

Links are clear now, 3 links, others are files:

  • l in the beginning of lrwxrwxrwx (l link, d directory, - normal file, c char device).

  • -> point to the target file.

user.dz
  • 48,105
  • Yes that solved it. So, i guess /usr/bin is only links. Good to know. Thank you! – Dimitris Feb 06 '14 at 12:55
  • No, you can create links in almost all places. But you create it there /usr/bin/su in your ln command – user.dz Feb 06 '14 at 12:57
  • Yes of course. I meant that /usr/bin is meant to host links and not the binaries. – Dimitris Feb 06 '14 at 13:00
  • Yes, in your case for your link . No, if you mean, /usr/bin hosts links only (as general rule). I updated my answer, Let me know if I should clarify more. – user.dz Feb 06 '14 at 13:19
0

If you used aliases to do it, as people in comments are asking you, you can temporally avoid the alias by tiping:

\su <restofthecommandhere>

The "\" tells bash to use the real command, ignoring the alias. Then, you can edit your .bashrc and remove the line making reference to this alias:

gedit $HOME/.bashrc
0

If you used an alias, the way to remove it is as follows:

  1. Temporarily remove it

    unalias su
    
  2. To permanently remove it, delete it from your .bashrc or .bash_aliases file.

Most likely you didn't link su to sublime text binary because doing that would have required sudo privileges. So just check if the first solution in the list works. If it works then and the problem reappears again later, you need to follow instruction 2.

sayantankhan
  • 1,691