|
|
|
|
|
|
| Author |
Message |
Christian *nix forums beginner
Joined: 11 Mar 2005
Posts: 36
|
Posted: Tue Feb 15, 2005 5:36 pm Post subject:
Re: User logged in
|
|
|
"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
|
Posted: Tue Feb 15, 2005 5:07 pm Post subject:
Re: User logged in
|
|
|
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
|
Posted: Tue Feb 15, 2005 3:54 pm Post subject:
User logged in
|
|
|
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 |
|
 |
|
|
The time now is Thu Jan 08, 2009 9:42 pm | All times are GMT
|
|
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
|
|