Linux.com

superuser

Link to this post 13 May 11

After you type sudo su, before you execute your script, type the path to your script.

Example, root@ubuntu:cd <path to your script> boo.

Link to this post 13 May 11

aznbun wrote:

Thank you.

The "./boo" worked. But I thought "./" was implied.

I thought by default "./boo" = "boo".

No. In fact, I find that to be a security flaw.

Link to this post 10 Jul 11

or put the commands in a path defined in your path section , for regular files will be ok in /usr/local/bin , this will make the command launchable simply via "boo"

Link to this post 28 Jul 11

Quick note:
The reason boo works for user X should be because of the fact that you have added /home/X/bin to the PATH (you can check the command out by writing echo $PATH in terminal). When switching to root the user no longer has any PATH entry to that particular folder thus writing boo checks folder /bin /sbin and such but cannot find the script. This is not true when using sudo since sudo is a nice way of doing su -c '/path/to/script/ sudo does the command as another user (namely root) and there the PATH is different :)

Hope that helped any other who wondered.

echo $PATH as user:
/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/XXX/bin

And sudo:
/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/XXX/bin

And as sudo su:
/sbin:/bin:/usr/sbin:/usr/bin

Note the difference. I'm using Centos so I'm not sure that sudo behaves in the same way on any other dist though.

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board