Puredyne/Adding Users and Groups
Adding new Users and Groups
Users and Groups
Access to a Linux system is based on users and groups. You need a user account and password to login. Every user also belongs to one or more groups. A group is a set of users who are "alike". For example, a group named audio might contain all users who work with audio and need access to the soundcard of a computer, while the group named plugdev might contain all users who need automount of pluggable storage devices. What groups you are in determines which files and hardware you can access and how you can access them. When you login, Linux remembers who you are, and makes access decisions based on your identity. The whoami command displays the current user. The groups command displays the user's groups.
Adding New Users
You can add new users with the adduser command. Open a terminal, go root and type adduser followed by the desired username. You will be prompted for a password for this new user, and various other information (full name, initial home directory, etc.).
Adding a User to a Group
When you create a new user, s/he is only part of one group, his/her own. This user will therefore not have permission to access any other files besides his/her own, and will not be able to fully access certain hardware, such as cdrom, modem, sound and video card. To give a user these rights, you need to add him/her to the groups s/he needs access to.
The default Live CD user, lintian, has access to the following groups:
lintian dialout cdrom floppy audio video plugdev powerdev
To add a new user to an existing group, use adduser again, followed by the username and name of the group you want to add the user to. To add luther to group audio, go root and do:
adduser luther audio
To add a user to multiple groups at once, use usermod, followed by -G and the names of the groups, then -a and the name of the user. Use a comma between the group names, no space! Another luther example:
usermod -G dialout,cdrom,floppy,audio,video,plugdev,powerdev -a luther
You can add new groups using the addgroup command, followed by the name of the group. And you can remove groups with groupdel.
To change your own or another users password, use passwd followed by the name of the user. To change the password for user luther, you go root and type passwd luther, you will be prompted for the new password twice.
You can remove users from a system using the deluser command. Open a terminal, go root and type deluser followed by some options (depending on your wished) and the name of the user to be removed. To view all options of deluser, type man deluser.
For instance, to remove user "luther" and his home folder, and making a backup of all files contained in the userhome and the mailspool-file to a file named luther.tar.bz2 or luther.tar.gz, you type:
deluser --remove-home --backup luther