FreeBSD pw command examples

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

Advertisement

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

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

3 comments… add one
  • Robert Oct 2, 2007 @ 8:17

    I found that it’s ‘pw user add name’ not ‘pw useradd name’ but thanks for the info!

  • Robert Oct 2, 2007 @ 8:18

    er also you don’t have to use the -n switch for the user name

  • someone Mar 15, 2009 @ 13:22

    You can either use ‘pw useradd’ or ‘pw user add’

    peace

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.