1833389 Members
2978 Online
110052 Solutions
New Discussion

odd who am i issue

 
rleon
Regular Advisor

odd who am i issue

I am logged in as rleon but the commands do not give me the correct output.

$ who am i
$ who
oracle pts/0 Mar 16 07:40
root pts/1 Mar 16 10:23
$ w
11:27am up 5 days, 20 mins, 2 users, load average: 0.09, 0.16, 0.21
User tty login@ idle JCPU PCPU what
oracle pts/0 7:40am 3:38 -ksh
root pts/1 10:23am -sh
$ pwd
/home/rleon
$

correct:

$ who am i
rleon pts/tg Mar 16 11:28
$ who
rleon pts/tg Mar 16 11:28
10 REPLIES 10
V. Nyga
Honored Contributor

Re: odd who am i issue

Hi,

what's about 'whoami' ?

Volkmar
*** Say 'Thanks' with Kudos ***
rleon
Regular Advisor

Re: odd who am i issue

On the "broken" system

$ whoami
rleon
$ who
oracle pts/0 Mar 16 07:40
root pts/1 Mar 16 10:23
$
James R. Ferguson
Acclaimed Contributor

Re: odd who am i issue

Hi:

You had 'su'ed users. Compare:

# whoami
# who am i

Regards!

...JRF...
V. Nyga
Honored Contributor

Re: odd who am i issue

Try 'who -m' (equivalent to who am i)

V.
*** Say 'Thanks' with Kudos ***
rleon
Regular Advisor

Re: odd who am i issue

$ who
oracle pts/0 Mar 16 07:40
root pts/1 Mar 16 10:23
root pts/2 Mar 16 12:29
$ who am i
$ who -m
$ whoami
rleon
$
Torsten.
Acclaimed Contributor

Re: odd who am i issue

Did you notice JRFs post?

man whoami

whoami prints your current user name, even if you have used su to
change it since your initial login (see su(1)). The command who am i
reports your initial login name because it uses /etc/utmp.

...

If you was another user before and did a "su", only whoami will list this user, all other commands will list the user you was before you did the su.

Hope this helps!
Regards
Torsten.

__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.

__________________________________________________
No support by private messages. Please ask the forum!

If you feel this was helpful please click the KUDOS! thumb below!   
rleon
Regular Advisor

Re: odd who am i issue

I did see the post but I did not do an su.

I am getting into the server via telnet.
But either way .. If I did su the command will return a user name. In this case nothing is returned.


$ who
oracle pts/0 Mar 16 07:40
$ who
oracle pts/0 Mar 16 07:40
$ whoami
rleon
$ who am i
$ who -m
$ hostname
sanantu1


So now this is odd ....
via telnet it does not work but if i ssh in it does.

$ who
oracle pts/0 Mar 16 07:40
rleon pts/1 Mar 16 13:17
$ who am i
rleon pts/1 Mar 16 13:17
$ who -m
rleon pts/1 Mar 16 13:17
$ whoami
rleon
$ w
1:18pm up 5 days, 2:11, 2 users, load average: 0.31, 0.26, 0.24
User tty login@ idle JCPU PCPU what
oracle pts/0 7:40am 5:28 -ksh
rleon pts/1 1:17pm w
$
$
$ hostname
sanantu1
William Tidwell
Occasional Advisor

Re: odd who am i issue

I think you have a damaged utmp file
rleon
Regular Advisor

Re: odd who am i issue

fixed it

Hi,

This should help from the from the technical knowledge base:

Regards
Michael

PROBLEM
who shows logins but no PID after a PC that was connected crashed and existed
incorrectly.
RESOLUTION
The utmp file can be manipulated with the fwtmp command.

1.check the last modification time of the /etc/utmp file
ls -l /etc/utmp
-rw-r--r-- 1 root root 1620 Jun 28 09:22 /etc/utmp

2.convert the binary /etc/utmp file to ascii :
/usr/sbin/acct/fwtmp /tmp/utmp.ascii

3.edit the /tmp/utmp.ascii file to remove the old entries
Note : the entries are sorted by date, simply use the login time reported
by
who(1) to find the lines to remove.

4.convert the file back to binary format :
/usr/sbin/acct/fwtmp -ic /tmp/utmp.binary

5.verify that all unwanted entries have been removed from the new file :
who /tmp/utmp.binary

6.verify that the /etc/utmp file has not been modified since the beginning of
this procedure :
ls -l /etc/utmp
-rw-r--r-- 1 root root 1620 Jun 28 09:22 /etc/utmp
If the file has been updated do all the steps again.

7.replace the existing /etc/utmp file with the new one :
mv /tmp/utmp.binary /etc/utmp

8.verify that the file still has the same ownership and permissions :
ls -l /etc/utmp
-rw-r--r-- 1 root root 1600 Jun 28 09:30 /etc/utmp

The who command will now report the correct information.

http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=75984
rleon
Regular Advisor

Re: odd who am i issue

$ who
oracle pts/0 Mar 16 07:40
rleon pts/ta Mar 16 14:04
$ whoami
rleon
$ who am i
rleon pts/ta Mar 16 14:04
$ w
2:06pm up 5 days, 2:59, 2 users, load average: 0.14, 0.17, 0.19
User tty login@ idle JCPU PCPU what
oracle pts/0 7:40am 32 -ksh
rleon pts/ta 2:04pm w
$