View previous topic :: View next topic |
Author |
Message |
Xiderpunk Tux's lil' helper
Joined: 05 Mar 2003 Posts: 149 Location: London, UK
|
Posted: Sat Jun 21, 2003 4:20 pm Post subject: Silly question.. |
|
|
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 |
|
|
Spida Tux's lil' helper
Joined: 08 Feb 2003 Posts: 97 Location: Germany
|
Posted: Sat Jun 21, 2003 4:31 pm Post subject: |
|
|
are you looking for
|
|
Back to top |
|
|
keratos68 Guru
Joined: 27 Dec 2002 Posts: 561 Location: Blackpool, Lancashire, UK.
|
Posted: Sat Jun 21, 2003 7:36 pm Post subject: |
|
|
Code: | awk#-F#\:#'#{#print#$1#"#is#UID#"#$3#}#'#/etc/passwd |
...substitute # for a single space!!
_________________ Someone told me that "..they only ever made one mistake...."
...and that's when they said they were wrong!! |
|
Back to top |
|
|
Timm Tux's lil' helper
Joined: 01 Nov 2002 Posts: 138 Location: Earth
|
Posted: Sat Jun 21, 2003 8:35 pm Post subject: |
|
|
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 |
|
|
keratos68 Guru
Joined: 27 Dec 2002 Posts: 561 Location: Blackpool, Lancashire, UK.
|
Posted: Sat Jun 21, 2003 8:42 pm Post subject: |
|
|
_________________ Someone told me that "..they only ever made one mistake...."
...and that's when they said they were wrong!! |
|
Back to top |
|
|
|