'su ' vs. 'su -'

'su ' vs. 'su -'

Post by paul » Sun, 27 May 2001 06:26:30



Hi

Let's say, I am logging with a userid. From that prompt, when switching to
root user, what's difference between
'su '  vs. 'su -' ?

--
Paul

 
 
 

'su ' vs. 'su -'

Post by Wayne Brow » Sun, 27 May 2001 07:11:11



> Let's say, I am logging with a userid. From that prompt, when switching to
> root user, what's difference between
> 'su '  vs. 'su -' ?

'su -' will give you root's permissions, as well as switch to root's
home directory, execute root's .profile, updates environment variables,
and so forth.  It's as if you had logged on as root in the first place.
'su ' gives you root's permissions, but it leaves you in the current
directory and doesn't execute any of root's profile scripts.

The same thing works with other users' ids.  'su - fred' gives you the
same environment fred gets when he logs in, but 'su fred' gives you
fred's identity without changing (most of) your current environment.

--
Wayne Brown                | "When your tail's in a crack, you improvise

http://betsyrandle.cjb.net |  your pelt to the trapper."
http://urbmyth.cjb.net     |           -- John Myers Myers, "Silverlock"

 
 
 

'su ' vs. 'su -'

Post by John Doher » Sun, 27 May 2001 07:25:10


| Let's say, I am logging with a userid. From that prompt, when switching to
| root user, what's difference between
| 'su '  vs. 'su -' ?

Straight from the man page:

  The following statements are true only if either /usr/bin/sh
  or  NULL  is  named  in  the  specified user's password file
  entry.  If the first argument to su is a ' - '  (dash),  the
  environment  is passed along unchanged, as if the user actu-
  ally logged  in  as  the  specified  user.   Otherwise,  the
  environment  is  passed  along, with the exception of $PATH,
  which is controlled by PATH and SUPATH in etc/default/su.

--

 
 
 

'su ' vs. 'su -'

Post by Aleksandar Milivojevi » Sun, 27 May 2001 07:20:18



> Hi

> Let's say, I am logging with a userid. From that prompt, when switching to
> root user, what's difference between
> 'su '  vs. 'su -' ?

"su" (on SVR4) will simply start root's shell with user ID set to
root, but all env variables, home directory, etc will stay unchanged
(behavior on BSD and Linux in this case is slightly different).

"su -" will give you same environment as when you login as root.

--

Opinions expressed herein are my own.
Statements included here may be fiction rather than truth.

 
 
 

'su ' vs. 'su -'

Post by paul » Thu, 31 May 2001 05:56:40


Hi ,

According to a few replies to my previous posting, 'su' without ' -' means
....it leaves you in the current  directory and doesn't execute any of
root's profile scripts..........

But, it looks like environment differs:

Let's say, I am logging in ,user name being 'test'. When I command 'set',
one of the result has following :
"PATH=/usr/local/bin:/usr/bin:/sbin:/usr/sbin:/usr/ccs/bin:/usr/ucb:/etc:/us
r/openwin/bin:/opt/SUNWspro/bin:."

But,
I wonder why after ,'su' without ' -', the result of 'set' command   is
different from that of 'test' user??
It is just"PATH=/usr/sbin:/usr/bin"!



> > Let's say, I am logging with a userid. From that prompt, when switching
to
> > root user, what's difference between
> > 'su '  vs. 'su -' ?

> 'su -' will give you root's permissions, as well as switch to root's
> home directory, execute root's .profile, updates environment variables,
> and so forth.  It's as if you had logged on as root in the first place.
> 'su ' gives you root's permissions, but it leaves you in the current
> directory and doesn't execute any of root's profile scripts.

> The same thing works with other users' ids.  'su - fred' gives you the
> same environment fred gets when he logs in, but 'su fred' gives you
> fred's identity without changing (most of) your current environment.

> --
> Wayne Brown                | "When your tail's in a crack, you improvise

> http://betsyrandle.cjb.net |  your pelt to the trapper."
> http://urbmyth.cjb.net     |           -- John Myers Myers, "Silverlock"

 
 
 

'su ' vs. 'su -'

Post by Ian Diddam » Thu, 31 May 2001 16:41:48


The prions in the brain of Wayne Brown awoke and formed the following ideas....

Quote:

>'su -' will give you root's permissions, as well as switch to root's
>home directory, execute root's .profile, updates environment variables,
>and so forth.  It's as if you had logged on as root in the first place.

This is exactly what I have always understood the case to be.

But then why is it if I login as (say) ian, a whoami gives the answer "ian".  
A subsequent "su -" certainly gives me root privileges etc and places me in
root's home directory etc etc etc....  but a whoami still answers "ian" !

Didds

 
 
 

'su ' vs. 'su -'

Post by Tony Walto » Thu, 31 May 2001 18:10:47



> The prions in the brain of Wayne Brown awoke and formed the following ideas....

> >'su -' will give you root's permissions, as well as switch to root's
> >home directory, execute root's .profile, updates environment variables,
> >and so forth.  It's as if you had logged on as root in the first place.

> This is exactly what I have always understood the case to be.

> But then why is it if I login as (say) ian, a whoami gives the answer "ian".
> A subsequent "su -" certainly gives me root privileges etc and places me in
> root's home directory etc etc etc....  but a whoami still answers "ian" !

Are you sure you mean "whoami" (as in /usr/ucb/whoami)"

It seems that /usr/ucb/whoami works as documented for me:

$ /usr/ucb/whoami
tonyw
$ su
Password:
# /usr/ucb/whoami
root
# exit
$ su -
Password:
Sun Microsystems Inc.   SunOS x.x       xxx     blah
# /usr/ucb/whoami
root

This is NOT the same as "/bin/who am i" which reports on who originally
logged in on a particular tty (or pseudotty) rather than on the current
"su-ness" that's in effect at a given time.

--
Tony

 
 
 

'su ' vs. 'su -'

Post by Philip Bro » Fri, 01 Jun 2001 07:21:36



>Are you sure you mean "whoami" (as in /usr/ucb/whoami)"

>It seems that /usr/ucb/whoami works as documented for me:

>$ /usr/ucb/whoami
>tonyw
>$ su
>Password:
># /usr/ucb/whoami
>root

'id' also works well, without resorting to /usr/ucb

--
[Trim the no-bots from my address to reply to me by email!]
[ Do NOT email-CC me on posts. Pick one or the other.]

The word of the day is mispergitude

 
 
 

1. restrict use of 'su' or 'su -'

Hello again,

how can I restrict the use of 'su' or 'su -' ? I want to make it impossible
that someone, who has an account, can ssh in and do all kinds of 'root'-
stuff...

Thanks for any tips or help.
Bart
------
RH6.2 kernel 2.2.18

2. Can't get 3Com 590C adaptor to work with 2.0.7 kernel

3. What is the difference between 'login: root' and 'su -' ?

4. sendfile to /dev/null

5. Socks 5 Proxy

6. MD5 disabled the 'su' and 'logon' command

7. help on mail server setup

8. 'su' and 'rlogin' wierdness under 2.6 ...

9. 'su' and 'LD_LIBRARY_PATH'

10. Can't 'su' from any account, ideas?

11. 'su -c' doesn't work properly?

12. what's the return value of 'su -c command' should be ?