1753439 Members
5109 Online
108794 Solutions
New Discussion юеВ

Re: Find it and mod it

 
SOLVED
Go to solution
Dennis Handly
Acclaimed Contributor

Re: Find it and mod it

>by only doing those accounts who's home directories reside in /home.

You could look at /home/*. Or you could change JRF's script to look at the home directory:
awk -F":" '$3 > 100 && index($6, "/home/") {
print $3, $4, $6
}' /etc/passwd | \
James R. Ferguson
Acclaimed Contributor

Re: Find it and mod it

Hi (again) Adam:

> I only ask because we have several "generic accounts" that have a higher than 100 UID and would possibly need to be excluded.

Given that you know the UID's of the accounts you want to exclude, just do:

#!/usr/bin/sh
awk -F":" '{if ($3>100 && $3 != 107 && $3 != 108) {print $3,$4,$6}}' /etc/passwd | \
while read UID GID DIR X
do
print "chown ${UID}:$GID ${DIR}/.profile"
done
exit

...which in this example, would exclude accounts whose UID is less than 100 along with accounts having UID=107 and UID=108. You can form any boolean condition you need.

Regards!

...JRF...
Adam W.
Valued Contributor

Re: Find it and mod it

Right on James, Thanks again!!!
There are two types of people in the world, Marines and those who wish they were.