Sflack Linux, like Slackware, is setup to use shadow passwords, so in addition to the standard /etc/passwd and /etc/group files, there is also an /etc/shadow file. Below is a list of files and programs you should be familiar with in order to successfully manage your users.
Adding a User
Sflack Linux makes adding a new user easy. All you have to do is run the /usr/sbin/adduser script. It will present you with a series of questions and then it will complete all of the necessary steps to get the account working.
After the account is setup, you can use the following programs to manage the account:
- /usr/bin/passwd – Changes the password.
- /usr/bin/chfn – Changes the finger information.
- /usr/bin/chsh – Changes the user’s login shell.
Removing a User
Removing a user is as simple as adding it; to do so you can either use the userdel command, or do it by hand.
userdel can’t remove an account if the user is currently logged in; so you must kill any running processes which belong to the user you are deleting.
Also, you have to run userdel -r (notice the -r flag) if you want to get rid of the home dir and mail spool of the user as well.
Removing a user manually requires editing a few files and removing some things, but it’s really quite simple. These steps a necessary to remove a user from the system:
- Remove the line in /etc/passwd. As root open the file /etc/passwd and find the line corresponding to the account you are removing and delete it.
- Remove the user name from /etc/group. You need to remove the username from any groups in the /etc/group file.
- Remove the line in /etc/shadow. Same process as in step 1.
- Delete the home directory. As root do an rm -rf on the home directory for the account.
- Delete the mail spool file. As root you need to delete /var/spool/mail/{USERNAME}.
Disabling a User
Disabling an account is easy and sometimes preferrable in certain situations. From the passwd(1) man page:
User accounts may be locked and unlocked with the -l and -u flags. The -l option disables an account by changing the password to a value which matches no possible encrypted value. The -u option re-enables an account by changing the password back to its previous value.