FreeBSDwiki:Users, adding

From Ubuntuwiki.net

Jump to: navigation, search

There are several methods that are commonly used to add users to a FreeBSD system.

Using pw to add a new user

samizdata## pw useradd username -g groupname -s /bin/csh -d /home/username

The command shown above will add a new user account named "username", assign the group "groupname" as the new user's primary group, set the C shell as its default shell on login, and set its home directory as "/home/username". It will not copy any .profile or similar files from /etc/skel, create any directories, or anything else - all pw does is manipulate the system user database for you.

See also: Modifying users

Using adduser to add a new user

adduser can be run with no arguments, and will present you with a prompt for each question that needs to be answered in order to create the user that you're going to create

dave@samizdata:~% su -
Password:
samizdata# adduser felix
Username: felix
Full name: Felix 
Uid (Leave empty for default):
Login group [felix]:
Login group is felix. Invite felix into other groups? []: wheel
Login class [default]:
Shell (sh csh tcsh tcsh bash) [sh]: bash
Home directory [/home/felix]:
Use password-based authentication? [yes]:
Use an empty password? (yes/no) [no]:
Use a random password? (yes/no) [no]:
Enter password:
Enter password again:
Lock out the account after creation? [no]:
Username   : felix
Password   : *****
Full Name  : Felix 
Uid        : 1002
Class      :
Groups     : felix wheel
Home       : /home/felix
Shell      : /usr/local/bin/bash
Locked     : no
OK? (yes/no): yes
adduser: INFO: Successfully added (felix) to the user database.
Add another user? (yes/no): n
Goodbye!
samizdata#

This will create the home directory of the new user, as well as manipulate the user database and groups database in order to add the user to the appropriate groups.

See also who for info on finding out who a system thinks you are on a particular system.

Personal tools