FreeBSD pw command examples

last updated in Categories ,

Q. How do I use FreeBSD pw command to add users?

A. The pw command is a command-line based editor for the system user and group files, allowing the superuser an easy to use and standardized way of adding, modifying and removing users and groups.

Add user called tom

To add a user called tom, enter:
# pw useradd -n tom -s /bin/csh -m
# passwd tom

Where,

  • -n tom : Username
  • -s /bin/csh : Set shell
  • -m : Create and setup home directory /home/tom

Delete a user called tom

Enter the command:
# pw userdel -n tom -r
Note that -r option remove home directory & its contents.

Getting help with pw command

For a summary of options available with each command, you can use
pw [command] help

For example, lists all available options for the useradd operation.
# pw useradd help
# man pw

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Share this on (or read 3 comments/add one below):

3 comment

    Have a question? Post it on our forum!