Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

after su"ing" to root, who was I? 3

Status
Not open for further replies.

hfaix

MIS
Nov 25, 2003
596
US
This sounds like a simple question, but I don't know the answer and couldn't find it on the web.

If I su to root, is there a command I can execute to tell me who I su"ed" from? Or who the lowest shell layers is occupied/owned by?

for example:

I login as user1
su to root

as root, can I determine who I am "logged" in as (user1)?

Thanks again-
 
Code:
MYTTY=`/usr/bin/tty`
last ${MYTTY##/dev/}  | head -1





Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L

 
su does not change the values of
$LOGIN && (and for ksh: $USER)
so: echo $LOGIN or $USER print the original user name
su - RESET them.
try: man su
 
Thanks again Rod. This is a good approach to it. I could script a scroll through sulog aswell, but I really wanted to do it via command. Yours does the trick.

iribach -

when passed with - , su does change the value of $LOGIN and $USER in ksh





 
hfaix
are: su - RESET them.
and: when passed with - , su does change
not exactly the SAME ??
 
Hiya hfaix,

You need to go into cd /var/adm
And then tail sulog
This will show you what you logged on as and if you su'd to another id.
At the command line if you type who am i
this will give you a number like pts/1 this is your terminal log in number. When you look at the sulog, look out for this number and the time you logged in and you should find a entry like:
SU 07/13 16:43 + pts/1 root-root
Showing that i logged on as root, but i also su'd to root.
Hope this helps :eek:)
 
hfaix
your last and my last are not compatible.
spamly
your approach WORKS
 
adelski (MIS) - Thanks for replying/participating. I knew I could do that approach. I just figured a single command was available. Rod always has a good answer.

iribach - I figured so. Is the su - RESET something for a different os (non AIX)? I would assume you're trying to su to user RESET. Thanks for your help.
 
OK hfaix
i oftener should use bold, italic, colors and other
modern things..
i see, it was not clear,
as you say i mean: su -\n
and not: su - user\n
sorry :)
why did we forgot the good && very old 'who am i' ?
 
spamly said:
Wouldn't "who am i" show this?

It certainly would (and does). Thanks spamly.

Rod Knowlton

Bespoke Wheel Reinvention - Ask me for a quote.
 
Wow.... now I'm feeling young.... I didn't even know there was a difference between whoami and who am i.

I think I was more confused then everyone. I guess I didn't read the type "who am i" close enough.



 
i also assumed whoami = "who am i". learn something every day.

IBM Certified -- AIX 4.3 Obfuscation
 
but to further muddy this discussion, i use su without the dash all the time, and in my env LOGIN=root and LOGNAME=myuserid after plain su. after su -, LOGNAME=root.

IBM Certified -- AIX 4.3 Obfuscation
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top