I Know That SU is preferred Over Sudo But Why?

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

Post Reply
Bradford1040
Baby Hen
Posts: 10
Joined: Wed Sep 26, 2012 22:50
Location: Virginia Beach, Virginia

I Know That SU is preferred Over Sudo But Why?

Post by Bradford1040 » Wed Oct 03, 2012 23:25

I wanted to know why SU is to be used over Sudo in this Distro, I understand that they are about the same thing anyway but some things require you to be in the Sudoers list, just dumb things like Dolphin when adding ROOT menu links and stuff like that. There may be other ways to do these things but I haven't found how.

I also don't understand why all distro's make being in the sudoers list a manual step, most that mess with TUX are able to easily add them self's yes but why add the extra step?

Just a question is all, not looking to change the wheel. I just was curious if there was a reason for both


akelling
Baby Hen
Posts: 4
Joined: Tue Oct 02, 2012 3:34

Re: I Know That SU is preferred Over Sudo But Why?

Post by akelling » Fri Oct 05, 2012 2:33

Thanks for the info I have been using Sabayon for along time and never knew that su - was preferred. I have used sudo command for most things without issue. It makes sense that the path would be different though.

Bradford1040
Baby Hen
Posts: 10
Joined: Wed Sep 26, 2012 22:50
Location: Virginia Beach, Virginia

Re: I Know That SU is preferred Over Sudo But Why?

Post by Bradford1040 » Mon Oct 08, 2012 1:49


Thank you! I did do a search on it but that page didn't come up, so thank you for the link with no look it up comment

caf4926
Baby Hen
Posts: 4
Joined: Sun Oct 07, 2012 17:58

Re: I Know That SU is preferred Over Sudo But Why?

Post by caf4926 » Mon Oct 08, 2012 7:01

su

or

su -

?

I use su -

Fitzcarraldo
Sagely Hen
Posts: 8218
Joined: Sat Mar 10, 2007 5:40
Location: United Kingdom
Contact:

Re: I Know That SU is preferred Over Sudo But Why?

Post by Fitzcarraldo » Mon Oct 08, 2012 11:59

su and su - are not quite the same thing. If you use 'su -' it's like logging in directly as root user from a VT. From the man page for su command:
-, -l, --login
Provide an environment similar to what the user would expect had the user logged in directly.

When - is used, it must be specified as the last su option. The other forms (-l and --login) do not have this restriction.

Code: Select all

[email protected] ~ $ su
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] ~ $

Code: Select all

[email protected] ~ $ su -
Password:
meshedgedx ~ # echo $SHELL
/bin/bash
meshedgedx ~ # whoami
root
meshedgedx ~ # echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.6.3
meshedgedx ~ # cd ~
meshedgedx ~ # pwd
/root
meshedgedx ~ # exit
logout
[email protected] ~ $
Compare the environments for the two:

Code: Select all

[email protected] ~ $ su
Password: 
meshedgedx fitzcarraldo # env
MANPATH=/etc/java-config-2/current-system-vm/man:/usr/local/share/man:/usr/share/man:/usr/share/gcc-data/x86_64-pc-linux-gnu/4.6.3/man:/usr/share/binutils-data/x86_64-pc-linux-gnu/2.22.90/man:/etc/java-config-2/current-system-vm/man/:/usr/lib64/php5.3/man/:/usr/lib64/php5.4/man/
KDE_MULTIHEAD=false
DM_CONTROL=/var/run/xdmctl
GPG_AGENT_INFO=/tmp/gpg-Mc4c1k/S.gpg-agent:6802:1
XDG_MENU_PREFIX=kde-4-
SHELL=/bin/bash
TERM=xterm
XDM_MANAGED=method=classic
XDG_SESSION_COOKIE=336f905c5bdf25b143f6bd6600000017-1349670357.870072-198293234
KONSOLE_DBUS_SERVICE=:1.90
GTK2_RC_FILES=/etc/gtk-2.0/gtkrc:/home/fitzcarraldo/.gtkrc-2.0:/home/fitzcarraldo/.gtkrc-2.0-kde4:/home/fitzcarraldo/.kde4/share/config/gtkrc-2.0
VBOX_APP_HOME=/opt/VirtualBox
KONSOLE_PROFILE_NAME=Shell
GS_LIB=/home/fitzcarraldo/.fonts
DBUS_SESSION_BUS_PID=6765
GTK_RC_FILES=/etc/gtk/gtkrc:/home/fitzcarraldo/.gtkrc:/home/fitzcarraldo/.kde4/share/config/gtkrc
WINDOWID=94371867
SYSFONT=latarcyrheb-sun16
SHELL_SESSION_ID=156ad51e489c4000aedcf227ae97a8d8
KDE_FULL_SESSION=true
ANT_HOME=/usr/share/ant
LC_ALL=en_GB.UTF-8
USER=root
LIBGL_DRIVERS_PATH=/usr/lib64/dri:/usr/lib32/dri
PRELINK_PATH_MASK=/usr/lib64/klibc:/usr/lib64/libfreebl3.so:/usr/lib64/libnssdbm3.so:/usr/lib64/libsoftokn3.so:/opt/bin/skype
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.pdf=00;32:*.ps=00;32:*.txt=00;32:*.patch=00;32:*.diff=00;32:*.log=00;32:*.tex=00;32:*.doc=00;32:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:
GUILE_LOAD_PATH=/usr/share/guile/1.8
GDK_USE_XFT=1
SESSION_MANAGER=local/meshedgedx:@/tmp/.ICE-unix/6858,unix/meshedgedx:/tmp/.ICE-unix/6858
OOO_FORCE_DESKTOP=gnome
PAGER=/usr/bin/less
CONFIG_PROTECT_MASK=/etc/gentoo-release /etc/sandbox.d /etc/php/cli-php5.3/ext-active/ /etc/php/cgi-php5.3/ext-active/ /etc/php/apache2-php5.3/ext-active/ /etc/php/cli-php5.4/ext-active/ /etc/php/cgi-php5.4/ext-active/ /etc/php/apache2-php5.4/ext-active/ /etc/fonts/fonts.conf /etc/gconf /etc/terminfo /etc/dconf /etc/ca-certificates.conf /etc/revdep-rebuild /etc/splash
FLTK_DOCDIR=/usr/share/doc/fltk-1.3.0-r1/html
XDG_CONFIG_DIRS=/etc/xdg
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DESKTOP_SESSION=KDE-4
LC_MESSAGES=en_GB.UTF-8
PWD=/home/fitzcarraldo
JAVA_HOME=/etc/java-config-2/current-system-vm
EDITOR=/bin/nano
JAVAC=/etc/java-config-2/current-system-vm/bin/javac
XCURSORS_THEME=Blue
KDE_SESSION_UID=1000
LANG=en_GB.UTF-8
GSETTINGS_BACKEND=dconf
GDM_LANG=en_GB.UTF-8
QT_GRAPHICSSYSTEM=raster
KONSOLE_DBUS_SESSION=/Sessions/1
HOME=/root
SHLVL=3
COLORFGBG=15;0
JDK_HOME=/etc/java-config-2/current-system-vm
LANGUAGE=en_GB.UTF-8
KDE_SESSION_VERSION=4
XCURSOR_THEME=Oxygen_Black
PYTHONPATH=/usr/lib/portage/pym
LOGNAME=root
LESS=-R -M --shift 5
CVS_RSH=ssh
GCC_SPECS=
XDG_DATA_DIRS=/usr/local/share:/usr/share
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-REhhvIhvbs,guid=962c01948f32e4e849b3100d507255d6
LESSOPEN=|lesspipe %s
R_HOME=/usr/lib64/R
INFOPATH=/usr/share/info:/usr/share/gcc-data/x86_64-pc-linux-gnu/4.6.3/info:/usr/share/binutils-data/x86_64-pc-linux-gnu/2.22.90/info:/usr/share/info/emacs-24
WINDOWPATH=7
DISPLAY=:0
PROFILEHOME=
USB_DEVFS_PATH=/dev/bus/usb
QT_PLUGIN_PATH=/usr/lib64/kde4/plugins:/home/fitzcarraldo/.kde4/lib64/kde4/plugins/:/usr/lib64/kde4/plugins/
RUBYOPT=-rauto_gem
LADSPA_PATH=/usr/lib64/ladspa
OPENGL_PROFILE=ati
SANE_CONFIG_DIR=/etc/sane.d
CONFIG_PROTECT=/usr/share/gnupg/qualified.txt /var/lib/hsqldb /usr/share/config /usr/share/openvpn/easy-rsa /usr/share/themes/oxygen-gtk/gtk-2.0
OPENCL_PROFILE=amd
XAUTHORITY=/root/.xauthwQgUVd
_=/bin/env
meshedgedx fitzcarraldo # exit
exit
[email protected] ~ $

Code: Select all

[email protected] ~ $ su -
Password: 
meshedgedx ~ # env
MANPATH=/etc/java-config-2/current-system-vm/man:/usr/local/share/man:/usr/share/man:/usr/share/gcc-data/x86_64-pc-linux-gnu/4.6.3/man:/usr/share/binutils-data/x86_64-pc-linux-gnu/2.22.90/man:/etc/java-config-2/current-system-vm/man/:/usr/lib64/php5.3/man/:/usr/lib64/php5.4/man/
SHELL=/bin/bash
TERM=xterm
VBOX_APP_HOME=/opt/VirtualBox
SYSFONT=latarcyrheb-sun16
LC_ALL=en_GB.UTF-8
ANT_HOME=/usr/share/ant
USER=root
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.pdf=00;32:*.ps=00;32:*.txt=00;32:*.patch=00;32:*.diff=00;32:*.log=00;32:*.tex=00;32:*.doc=00;32:*.aac=00;36:*.au=00;36:*.flac=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.axa=00;36:*.oga=00;36:*.spx=00;36:*.xspf=00;36:
PRELINK_PATH_MASK=/usr/lib64/klibc:/usr/lib64/libfreebl3.so:/usr/lib64/libnssdbm3.so:/usr/lib64/libsoftokn3.so:/opt/bin/skype
LIBGL_DRIVERS_PATH=/usr/lib64/dri:/usr/lib32/dri
GUILE_LOAD_PATH=/usr/share/guile/1.8
GDK_USE_XFT=1
PAGER=/usr/bin/less
CONFIG_PROTECT_MASK=/etc/gentoo-release /etc/sandbox.d /etc/php/cli-php5.3/ext-active/ /etc/php/cgi-php5.3/ext-active/ /etc/php/apache2-php5.3/ext-active/ /etc/php/cli-php5.4/ext-active/ /etc/php/cgi-php5.4/ext-active/ /etc/php/apache2-php5.4/ext-active/ /etc/fonts/fonts.conf /etc/gconf /etc/terminfo /etc/dconf /etc/ca-certificates.conf /etc/revdep-rebuild /etc/splash
XDG_CONFIG_DIRS=/etc/xdg
FLTK_DOCDIR=/usr/share/doc/fltk-1.3.0-r1/html
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.6.3
LC_MESSAGES=en_GB.UTF-8
PWD=/root
JAVA_HOME=/etc/java-config-2/current-system-vm
JAVAC=/etc/java-config-2/current-system-vm/bin/javac
XCURSORS_THEME=Blue
EDITOR=/bin/nano
LANG=en_GB.UTF-8
GSETTINGS_BACKEND=dconf
GDM_LANG=en_GB.UTF-8
QT_GRAPHICSSYSTEM=raster
JDK_HOME=/etc/java-config-2/current-system-vm
SHLVL=1
HOME=/root
LANGUAGE=en_GB.UTF-8
PYTHONPATH=/usr/lib/portage/pym
LESS=-R -M --shift 5
LOGNAME=root
GCC_SPECS=
CVS_RSH=ssh
XDG_DATA_DIRS=/usr/local/share:/usr/share
LESSOPEN=|lesspipe %s
R_HOME=/usr/lib64/R
INFOPATH=/usr/share/info:/usr/share/gcc-data/x86_64-pc-linux-gnu/4.6.3/info:/usr/share/binutils-data/x86_64-pc-linux-gnu/2.22.90/info:/usr/share/info/emacs-24
DISPLAY=:0
USB_DEVFS_PATH=/dev/bus/usb
RUBYOPT=-rauto_gem
QT_PLUGIN_PATH=/usr/lib64/kde4/plugins
OPENGL_PROFILE=ati
LADSPA_PATH=/usr/lib64/ladspa
SANE_CONFIG_DIR=/etc/sane.d
CONFIG_PROTECT=/usr/share/gnupg/qualified.txt /var/lib/hsqldb /usr/share/config /usr/share/openvpn/easy-rsa /usr/share/themes/oxygen-gtk/gtk-2.0
OPENCL_PROFILE=amd
XAUTHORITY=/root/.xauth5gs4UP
_=/usr/bin/env
meshedgedx ~ # exit
logout
[email protected] ~ $ 
Either 'su -' or 'su' should be fine with Gentoo and SL. I use su and have never had any problems.

caf4926
Baby Hen
Posts: 4
Joined: Sun Oct 07, 2012 17:58

Re: I Know That SU is preferred Over Sudo But Why?

Post by caf4926 » Mon Oct 08, 2012 13:20

I use su and have never had any problems
99% of the time you shouldn't

I'm new to sabayon, so I'll live and learn

Post Reply