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
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
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"
| 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.
--
> 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 same environment as when you login as root.
--
Opinions expressed herein are my own.
Statements included here may be fiction rather than truth.
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', But,
> 'su -' will give you root's permissions, as well as switch to root's > The same thing works with other users' ids. 'su - fred' gives you the > --
one of the result has following :
"PATH=/usr/local/bin:/usr/bin:/sbin:/usr/sbin:/usr/ccs/bin:/usr/ucb:/etc:/u
r/openwin/bin:/opt/SUNWspro/bin:."
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 -' ?
> 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.
> 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"
This is exactly what I have always understood the case to be.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.
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
> 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" !
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
>It seems that /usr/ucb/whoami works as documented for me:
>$ /usr/ucb/whoami
>tonyw
>$ su
>Password:
># /usr/ucb/whoami
>root
--
[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 -' ?
6. MD5 disabled the 'su' and 'logon' command
8. 'su' and 'rlogin' wierdness under 2.6 ...
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 ?