A script for deleting user , if he has no login shell.
I want to create a script to delete user if he has no login shell.
|
Please, can you elaborate? What do you mean for "user that has no login shell"? All the system users (those one needed by some system services or specific applications) have no login shell. If you delete them, a lot of stuff will stop working!
|
Excellent! Where to begin?
Maybe use a shell loop, read the /etc/passwd file line by line, check the 7th field to see what shell it is, if any, and depending on which it is (or not), add the username (field #1 in the file) to a list (an array perhaps?) of "TO BE REMOVED" users. Once the passwd file has been processed, execute `userdel` on each of the usernames in your list of users to be removed. Meanwhile, consider reporting your thread, and asking for a move to /Programming, if you agree it might be a better place for this topic. Cheers & good luck! OH and P.S. - colucix makes a VERY good point!! How will you know which users you can safely delete? |
Quote:
Again, as with most of your threads, try providing some useful information, like what you want to write this in (BASH? Perl? Ruby? What??), and what parameters you want for the program. And again, post SPECIFIC questions...we aren't going to write the script for you. |
Het guys Sorry! My question is wrong!
|
All times are GMT -5. The time now is 05:02 PM. |