Help with who am i . Not displaying real user


 
Thread Tools Search this Thread
Operating Systems Solaris Help with who am i . Not displaying real user
# 1  
Old 03-17-2011
Help with who am i . Not displaying real user

Hi

I'm trying to get the real username of any user running as root on my server. On one of my server running Sol 10, if I su to root and run who am i, it displays my username. which is what I want.

But when I run it on another server, this time on Sol 8, it displays root as the user. Is there anyway to get the actual user name?

Thank you in advance
# 2  
Old 03-17-2011
Try
Code:
id -un

# 3  
Old 03-17-2011
sorry that does not work..... illegal option.
# 4  
Old 03-17-2011
Code:
/usr/xpg4/bin/id -un

# 5  
Old 03-17-2011
Great! works...thanks!Smilie

---------- Post updated at 09:47 AM ---------- Previous update was at 09:38 AM ----------

Spoke too soon, ignore my previous post.... didn't work when I su to root and ran it.

Anyway, I found a way round it with the command below... strange though!
w -h |cut -f1 -d" " |uniq`
# 6  
Old 03-17-2011
Quote:
Originally Posted by wisdom
Spoke too soon, ignore my previous post.... didn't work when I su to root and ran it.
Then please define better what output you expect depending on the various cases.
Quote:
Anyway, I found a way round it with the command below... strange though!
w -h |cut -f1 -d" " |uniq
This is quite weak, especially if more than one user is logged in.
# 7  
Old 03-18-2011
Quote:
Originally Posted by jlliagre
Then please define better what output you expect depending on the various cases.
This is quite weak, especially if more than one user is logged in.
Very true.....
The required output is to display the real username, instead of displaying root as the user.
who am seems to work ok on my sol 10 servers, but on this sol 8, it's not. It keeps displaying that the real user is root.

Note I su to root on the server as opposed to login in as root. So it should really display my login name.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Real, effective and saved user id in C program

I figured it out by now. (0 Replies)
Discussion started by: Ralph
0 Replies

2. UNIX for Advanced & Expert Users

Regarding real example of user of semicolon(;) and + in find/exec command.

Hello All, Was recently working on an requirement where we have to search files more than a specific number, following is the example on same. Let's say file names are test_40000.txt,test_40001.txt and so on till test_99999.txt. Now requirement was to search from find command only those... (1 Reply)
Discussion started by: RavinderSingh13
1 Replies

3. Shell Programming and Scripting

Adding user name to file, and then displaying new line number

Hi all - I'm completely stumped by a script I'm working on... The short version is I have a file called 'lookup' and in it are hundreds of names (first and last). I have a script that basically allows the user to enter a name, and what I need to have happen is something like this: Record... (8 Replies)
Discussion started by: sabster
8 Replies

4. Shell Programming and Scripting

Wget script to simulate real user visits

so i'm using the following script to attempt to simulate a user visiting a page but unfortunately, it doesn't look like this is working: wget -nv -r "http://www.mywebsite.com" does anyone have a better idea of how to do this? the goal here is to run a wget command from a linux host to a... (3 Replies)
Discussion started by: SkySmart
3 Replies

5. Shell Programming and Scripting

In real time - what user connects or disconnect

Write a tool that will be displayed in real time, what user connects or disconnects from a system that uses this tool :)) Maybe anyone can help me? (2 Replies)
Discussion started by: titasas
2 Replies

6. Shell Programming and Scripting

Displaying default values when accepting input from user

Is there a way to display the default answer when accepting input from the user in the unix script.. e.g. ans="n" read $ans?"Enter y to continue n to exit:" altough ans contains n the message doesn't display the current contents on ans .. you get Enter y to continue n to exit: (8 Replies)
Discussion started by: flopster
8 Replies

7. Shell Programming and Scripting

Displaying current user process

When I typed in ps -a I get this: PID TTY TIME CMD 31799 pts/3 00:00:00 vim 31866 pts/3 00:00:00 vim And to check who is currently logged in, I type who Felix Whoals Tada Whoals Lala Whoals How can I get the user process for all current users who logged in?? I think I need to combine... (14 Replies)
Discussion started by: felixwhoals
14 Replies

8. Shell Programming and Scripting

how to get real user name

I know that in order to get a real user name I should use the following command: cut -d: -f5 /etc/passwd. But how can I get the real user name for those users who are currently logged in to the system??? :confused: Can somebody help me??? (3 Replies)
Discussion started by: aga
3 Replies

9. Shell Programming and Scripting

Collecting & Displaying of Last User ID and Date of Last Login

Hi, I needed to write a script to "Collect and Display the Last User ID and Date of Last Login". The requirement is: When a workstation stops reporting it could be for many reasons. If we know the last person who logged in before the workstation came down, then we can contact the last... (1 Reply)
Discussion started by: amittal
1 Replies

10. UNIX for Dummies Questions & Answers

Collecting & Displaying of Last User ID and Date of Last Login

Hi, I needed to write a script to "Collect and Display the Last User ID and Date of Last Login". The requirement is: When a workstation stops reporting it could be for many reasons. If we know the last person who logged in before the workstation came down, then we can contact the last... (1 Reply)
Discussion started by: amittal
1 Replies
Login or Register to Ask a Question