how to get real user name


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to get real user name
# 1  
Old 08-01-2007
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??? Smilie Can somebody help me???
# 2  
Old 08-01-2007
who | awk -F' ' '{ print $1 }' | sort | uniq > list2; while read record; do cat /etc/passwd | grep $record | cut -d: -f5; done < list2; rm list2

Smilie
# 3  
Old 08-01-2007
This will give you more information of who is logged in -- just cut what you need:
Code:
finger -fs `who -q | egrep -v '# users'`

# 4  
Old 08-01-2007
Thanks for your hint but is it possible to do this without using the 'awk' command???
Login or Register to Ask a Question

Previous Thread | Next Thread

6 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

Log all the commands input by user at real time in /var/log/messages

Below is my script to log all the command input by any user to /var/log/messages. But I cant achieve the desired output that i want. PLease see below. function log2syslog { declare COMMAND COMMAND=$(fc -ln -0) logger -p local1.notice -t bash -i -- "$USER:$COMMAND" } trap... (12 Replies)
Discussion started by: invinzin21
12 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. Solaris

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... (9 Replies)
Discussion started by: wisdom
9 Replies

6. 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
Login or Register to Ask a Question