equo : why sudo should not be use ?

If you are new to Linux or new to Sabayon Linux and just not sure where to post, here ya go. Post without fear of being told to RTFM :-)

Moderator: Moderators

equo : why sudo should not be use ?

Postby bcostacurta » Sat Jun 16, 2012 17:27

Hello,

I'm just wondering why the documentation about using equo reckons *not* to use sudo.

http://wiki.sabayon.org/index.php?title ... nux_kernel

Which works vey fine. No problem there, only curiosity : why equo should not be used prefixed with sudo ?
I understood sudo whas indeed a way to run commands under root using using root which is considered as more secure.

Thanks for clarification

Bye,
Bruno
bcostacurta
Baby Hen
 
Posts: 8
Joined: Fri Mar 02, 2012 12:15

Re: equo : why sudo should not be use ?

Postby Fitzcarraldo » Sat Jun 16, 2012 23:33

su and sudo behave in subtly different ways by design, as you can see in the examples below.

Look at the path and default directory when I am logged in under my own user name (fitzcarraldo):

Code: Select all
[email protected] ~ $ echo $SHELL
/bin/bash
[email protected] ~ $ whoami
fitzcarraldo
[email protected] ~ $ echo $PATH
/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.4.2:/opt/blackdown-jdk-1.4.2.03/bin:/opt/blackdown-jdk-1.4.2.03/jre/bin:/usr/games/bin
[email protected] ~ $ cd ~
[email protected] ~ $ pwd
/home/fitzcarraldo
[email protected] ~ $

Now see what the path and default directory are when I use the sudo command:

Code: Select all
[email protected] ~ $ echo $SHELL
/bin/bash
[email protected] ~ $ sudo -s whoami
Password: <---- Here I have to enter user fitzcarraldo's password
root
[email protected] ~ $ sudo -s echo $PATH
/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.4.2:/opt/blackdown-jdk-1.4.2.03/bin:/opt/blackdown-jdk-1.4.2.03/jre/bin:/usr/games/bin
[email protected] ~ $ sudo -s cd ~
[email protected] ~ $ pwd
/home/fitzcarraldo
[email protected] ~ $

N.B. The sudo man page tells you that the -s (shell) option runs the shell specified by the SHELL environment variable if it is set or the shell as specified in passwd. If a command is specified, it is passed to the shell for execution. Otherwise, an interactive shell is executed.

Now see what the path and default directory are when I am the root user:

Code: Select all
[email protected] ~ $ su
Password: <---- Here I have to enter the root user's password
meshedgedx fitzcarraldo # echo $SHELL
/bin/bash
meshedgedx fitzcarraldo # whoami
root
meshedgedx fitzcarraldo # echo $PATH
/sbin:/bin:/usr/sbin:/usr/bin
meshedgedx fitzcarraldo # cd ~
meshedgedx ~ # pwd
/root
meshedgedx ~ # exit
exit
[email protected] ~ $


As you can see above, the path and default directory are not the same if you use the sudo and su commands.
User avatar
Fitzcarraldo
Sagely Hen
 
Posts: 7981
Joined: Sat Mar 10, 2007 5:40
Location: United Kingdom


Return to Beginners|Newbies Area

Who is online

Users browsing this forum: No registered users and 2 guests