Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Silly question..
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Xiderpunk
Tux's lil' helper
Tux's lil' helper


Joined: 05 Mar 2003
Posts: 149
Location: London, UK

PostPosted: Sat Jun 21, 2003 4:20 pm    Post subject: Silly question.. Reply with quote

Noobish question..

How do I list the UID's of all the current users at the shell prompt?

I have tried searching everywhere for the answer to this with no joy, everything refers to php, other systems etc etc.
Back to top
View user's profile Send private message
Spida
Tux's lil' helper
Tux's lil' helper


Joined: 08 Feb 2003
Posts: 97
Location: Germany

PostPosted: Sat Jun 21, 2003 4:31 pm    Post subject: Reply with quote

are you looking for
Code:
cat /etc/passwd
Back to top
View user's profile Send private message
keratos68
Guru
Guru


Joined: 27 Dec 2002
Posts: 561
Location: Blackpool, Lancashire, UK.

PostPosted: Sat Jun 21, 2003 7:36 pm    Post subject: Reply with quote

Code:
awk#-F#\:#'#{#print#$1#"#is#UID#"#$3#}#'#/etc/passwd


...substitute # for a single space!!

:wink:
_________________
Someone told me that "..they only ever made one mistake...."

...and that's when they said they were wrong!!
Back to top
View user's profile Send private message
Timm
Tux's lil' helper
Tux's lil' helper


Joined: 01 Nov 2002
Posts: 138
Location: Earth

PostPosted: Sat Jun 21, 2003 8:35 pm    Post subject: Reply with quote

Quote:

How do I list the UID's of all the current users at the shell prompt?

I guess you mean "connected" on the console. What about this:

Code:
#!/bin/bash
for name in $(users)
do
   uinf=$(cat /etc/passwd | grep $name)
   if [ -z "$uinf" ]
   then
     echo "User listed in users does not exists in /etc/passwd"
   else
     usr=$(echo $uinf | cut -f1 -d:)
     id=$(echo $uinf | cut -f3 -d:)
     echo "User $usr UID $id"
   fi
done


I hate "oneliner" :) [/quote]
_________________
Timm
Back to top
View user's profile Send private message
keratos68
Guru
Guru


Joined: 27 Dec 2002
Posts: 561
Location: Blackpool, Lancashire, UK.

PostPosted: Sat Jun 21, 2003 8:42 pm    Post subject: Reply with quote

:twisted:
_________________
Someone told me that "..they only ever made one mistake...."

...and that's when they said they were wrong!!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum