MicroBSD Handbook

Prev Next

7.6 Modifying Accounts

There are a variety of different commands available in the Unix environment to manipulate user accounts. The most common commands are summarized below, followed by more detailed examples of their usage.

Command Summary
adduser The recommended command-line application for adding new users.
rmuser The recommended command-line application for removing users.
chpass A flexible tool to change user database information.
passwd The simple command-line tool to change user passwords.
pw A powerful and flexible tool to modify all aspects of user accounts.

7.6.1 adduser

adduser is a simple program for adding new users. It creates entries in the system passwd and group files. It will also create a home directory for the new user, copy in the default configuration files (``dotfiles'') from /usr/share/skel, and can optionally mail the new user a welcome message.

To create the initial configuration file, use adduser -s -config_create. Next, we configure adduser defaults, and create our first user account, since using root for normal usage is evil and nasty.

Example of adduser

# adduser -v
	Use option ``-silent'' if you don't want to see all warnings and questions.

	Reading /etc/shells
	Check /etc/master.passwd
	Check /etc/group
	
	Ok, let's go.
	Don't worry about mistakes. I will give you the chance later to correct any input.
	Enter username [a-z0-9_-]: pesho
	Enter full name []: Test 1
	Enter shell csh ksh nologin sh tcsh [tcsh]:
	Uid [1002]:
	Login group pesho [pesho]:
	Login group is ``pesho''. Invite pesho into other groups: guest no
	[no]:
	Enter password []:
	Enter password again []:
	
	Name:     pesho
	Password: ****
	Fullname: Test 1
	Uid:      1002
	Gid:      1002 (pesho)
	Groups:   pesho
	HOME:     /home/pesho
	Shell:    /bin/tcsh
    	OK? (y/n) [y]: y
	Added user ``pesho''
	Copy files from /etc/skel to /home/pesho
	Add another user? (y/n) [y]: n
	Goodbye!
    #

7.6.2 rmuser

You can use rmuser to completely remove a user from the system. rmuser performs the following steps:

  1. Removes the user's crontab entry (if any).

  2. Removes any at jobs belonging to the user.

  3. Kills all processes owned by the user.

  4. Removes the user from the system's local password file.

  5. Removes the user's home directory (if it is owned by the user).

  6. Removes the incoming mail files belonging to the user from /var/mail.

  7. Removes all files owned by the user from temporary file storage areas such as /tmp.

  8. Finally, removes the username from all groups to which it belongs in /etc/group.



If a group becomes empty and the group name is the same as the username, the group is removed; this complements the per-user unique groups created by adduser.

rmuser cannot be used to remove superuser accounts, since that is almost always an indication of massive destruction.

By default, an interactive mode is used, which attempts to make sure you know what you are doing.

Example of rmuser

# rmuser pesho
	Matching password entry:

	pesho:$2a$07$FiQ9FpGeJdgbuszAeSDa/urgLawu2DRbpfOFvEWu0pI1P/hmNiB..:1002:1002::0:0:Test 1:/home/pesho:/bin/tcsh
	
	Is this the entry you wish to remove? y
	Remove user's home directory (/home/pesho)? y
	Updating password file, updating databases, done.
	Updating group file:Removing group pesho -- personal group is empty
	 done.
	Removing user's home directory (/home/pesho): done.
    #

7.6.3 chpass

chpass changes user database information such as passwords, shells, and personal information.

Only system administrators, as the superuser, may change other users' information and passwords with chpass.

When passed no options, aside from an optional username, chpass displays an editor containing user information. When the user exists from the editor, the user database is updated with the new information.

Example of chpass

# chpass pesho
	# Changing user database information for pesho.
	Login: pesho
	Encrypted password: $2a$07$1ncUlyxLFvASpuslb/0rv.903lkGxQAHg4fHhU.UuswBhTJHsx2tS
	Uid [#]: 1002
	Gid [# or name]: 1002
	Change [month day year]:
	Expire [month day year]:
	Class:
	Home directory: /home/pesho
	Shell: /bin/tcsh
	Full Name: TEST 1
	Office Location:
	Office Phone:
	Home Phone:
	

chfn and chsh are just links to chpass, as are ypchpass, ypchfn, and ypchsh. NIS support is automatic, so specifying the yp before the command is not necessary. If this is confusing to you, do not worry.

7.6.4 passwd

passwd is the usual way to change your own password as a user, or another user's password as the superuser.

Example of passwd

{3} passwd
	Changing local password for pesho.
	Old password:
	New password:
	Retype new password:
	

Example of Changing Another User's Password as the Superuser

# passwd pesho
    Changing local password for pesho.
    New password:
    Retype new password:

7.6.5 pw

pw is a command line utility to create, remove, modify, and display users and groups. It functions as a front end to the system user and group files. pw has a very powerful set of command line options that make it suitable for use in shell scripts, but new users may find it more complicated than the other commands presented here.


Prev Home Next
User Accounts Limiting Users

This, and other documents, can be downloaded from MicroBSD.

For questions about MicroBSD, read the documentation before contacting <MicroBSD Support>.
Copyright © 1995-2003 by The FreeBSD Documentation Project, OpenBSD FAQ Copyright © 1998-2003 OpenBSD, Modified for MicroBSD