Hello FreeBSD Geeks.
As you may know, on FreeBSD Systems you have to invoke the pw command to run the generical useradd command.
Syntax: pw useradd [options] user
This is the most usefull useradd command, from my point of view:
This creates the user anakin, with /home/starwars as homedir and bash as the user’s default shell.
-m is for creating the homedir if it doesn’t exist and copy the data from the /etc/skel folder in the freshly new created dir. if the folder already exists, nothing will be copied from the /etc/skel dir. -d is for setting the home directory, -c is for adding a comment about the user and -s is for choosing the login shell.
# pw useradd -m -d /home/starwars -c "the anakin user" -s /usr/local/bin/bash anakin
Other useradd usefull arguments:
- -u UID : create the user with the specified user id.
- -U : create a group with the user’s name and add the user to the group
- -g : specify the group ID (GID) or group name in which the user will be included.
- -o : allow this user to have a non unique UID
To set the password for the user, use the passwd command and type the password twice:
# passwd user
Other commands running with pw:
- userdel ===> pw userdel
- usermod ===> pw usermod
- usershow ===> pw usershow
- groupadd ===> pw groupadd
- groupdel ===> pw groupdel
- groupmod ===> pw groupmod
- lock ===> pw lock
- unlock ===> pw unlock