Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
CAVEATS
userdel will not allow you to remove an account if there are running processes which belong to this account. In that case, you may have to kill those processes or lock the user's password or account and remove the account later.
How do I lock an user account or password? Only with usermod -L?
When I want to stop an user from logging into a system, but keep his files (e.g., to be analysed or just kept), is one of these best or bad?
- just locking the account, or
- remove his account but keeping his files, or
- backup his files and removing the user completely
What choices would have the same steps across most flavors of systems?
Locking the account should prevent login. Off hand, I think you could also set the login terminal to /bin/false and accomplish the same thing. A simple option would be, as root, to change their password to something that they would have an extremely hard time guessing.
It is always a good practice to remove the user account when you know that this account will not be used in future. However, if you have scenario wherein there are chances of that user coming back then it is better to keep his account disabled for that time frame.
Let me put it in simple way. Disable the user account using usermod -L for a month. If that user does not comes back then delete the user account. Ofcourse you have to maintain a sheet which will keep a record when you have disabled the user account and when you should delete it.
It is always a good idea to retain the data belongs to the user you will going to delete for audit purpose. You can find out the files that were owned/created by the user using find / -user <username> command.
Procedure will look like as follows:
1. Disable the user account and keep it disabled for a month.
2. If your comes back within a month re-enable the account, reset the password and give credential to the user.
3. If user does not comes back then find out all the files owned/created by him using find command. Make a copy of it under some backup directory and delete the user account.
What choices would have the same steps across most flavors of systems?
I have a procedure that I follow on both GNU/Linux and FreeBSD systems. (Note that - for FreeBSD - some commands differ from what I'll post below.) As a general rule, I do not remove old accounts. UIDs are preserved/retired when users leave, for auditing purposes.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.