We help IT Professionals succeed at work.

Remove User Info from password file etc...

bross073097
bross073097 asked
on
Medium Priority
248 Views
Last Modified: 2010-03-04
I'm looking for a small piece of code that will read a file:

One user per line.
user1
user2
user3

Read this file, then find that user in the password file and remove the line that they are listed in. Then delete their /home/user1 directory and any sub directories, then delete their /var/spool/mail/user1 mail box.

Thanks in advance.
Bob Ross

Comment
Watch Question

Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
That was a big program. All the other things were so small I didn't realize. It prompts for a user name. Is there a way to get it to read a file (killuser.dat) that has one user per line listed and remove thos users. If it's too much don't worry about it. I could always enter them in one at a time.

user1
user2
user3

and so on.

Thanks
Bob Ross

Author

Commented:
OK, I tried it, and it went thru all th motions, and even said it did what was wanted but the password line, home directory, and mail box are still there.

Thanks
Bob

Author

Commented:
Ok I got it to work.

It had to many in the passwd I only had user:passwd:uid:gid:Real Name:home_dir:shell

I removed the others and it worked.

I found that the passwd.new.#### was the updated passwd file.

Will it be easy to get it to do this from the killuser.dat file??

Then to replace the old passwd file with the new. Just looking for automation so someone else can do this when I out of town for a few weeks.

Thanks
Bob

Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.