niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Programming » shell
User logged in
Post new topic   Reply to topic Page 1 of 1 [3 Posts] View previous topic :: View next topic
Author Message
Christian
*nix forums beginner


Joined: 11 Mar 2005
Posts: 36

PostPosted: Tue Feb 15, 2005 5:36 pm    Post subject: Re: User logged in Reply with quote

"Icarus Sparry" <usenet@icarus.freeuk.com> a écrit dans le message de
news:slrnd14eje.kbg.usenet@icarus.freeuk.com...
Quote:
On 2005-02-15, Christian <cgregoir99@yahoo.com> wrote:
Hello,

Is there a way to know, from one user account, which user account I
logged
in from ?

Say :

# id
user1
# su - user2
# id
user2
# <some_cmd

where some_cmd would return user1.

I've written a script that does the trick, using the command 'last' and
checking if any user is logged in on the same tty as the current one.
But if there is a cleaner way ...

Most login systems change the ownership of the tty to the person when
they log in, so that they can use commands like 'mesg'. If yours does,
then all you need to do is work out who owns your terminal.

ls -lL $(tty) | awk '{print $3}'

Or you can use the command

who am i

which looks in the current login records.

Great ! 'who am i' is just what I needed.

Thanks
Back to top
Icarus Sparry
*nix forums Guru


Joined: 19 Feb 2005
Posts: 342

PostPosted: Tue Feb 15, 2005 5:07 pm    Post subject: Re: User logged in Reply with quote

On 2005-02-15, Christian <cgregoir99@yahoo.com> wrote:
Quote:
Hello,

Is there a way to know, from one user account, which user account I logged
in from ?

Say :

# id
user1
# su - user2
# id
user2
# <some_cmd

where some_cmd would return user1.

I've written a script that does the trick, using the command 'last' and
checking if any user is logged in on the same tty as the current one.
But if there is a cleaner way ...

Most login systems change the ownership of the tty to the person when
they log in, so that they can use commands like 'mesg'. If yours does,
then all you need to do is work out who owns your terminal.

ls -lL $(tty) | awk '{print $3}'

Or you can use the command

who am i

which looks in the current login records.
Back to top
Christian
*nix forums beginner


Joined: 11 Mar 2005
Posts: 36

PostPosted: Tue Feb 15, 2005 3:54 pm    Post subject: User logged in Reply with quote

Hello,

Is there a way to know, from one user account, which user account I logged
in from ?

Say :

# id
user1
# su - user2
# id
user2
# <some_cmd>

where some_cmd would return user1.

I've written a script that does the trick, using the command 'last' and
checking if any user is logged in on the same tty as the current one.
But if there is a cleaner way ...

Thanks in advance.

Christian
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [3 Posts] View previous topic :: View next topic
The time now is Thu Jan 08, 2009 9:42 pm | All times are GMT
navigation Forum index » Programming » shell
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts postfix smtp authentication using mysql stored user/pass rtresidd Postfix 0 Fri Oct 03, 2008 5:58 am
No new posts User Environment - export PATH variable paalepu AIX 0 Tue Sep 12, 2006 8:12 pm
No new posts Capturing user login Information of windows sachin PHP 3 Fri Jul 21, 2006 5:44 am
No new posts Recommend an email program for the debian-user-digest? DJ Hackenbruch Debian 5 Fri Jul 21, 2006 3:20 am
No new posts equivalent of MAIL>SET FORWARD/USER=ME YOU on unix VAXman-@SendSpamHere.ORG VMS 4 Thu Jul 20, 2006 7:56 pm

Loans | Credit Cards | Personal Loans | Debt Consolidation | Debt Consolidation
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1421s ][ Queries: 20 (0.0703s) ][ GZIP on - Debug on ]