Forrest logo
back to the useradd tool

useradd:tldr:5c99f

useradd: Create a new user with the home directory filled by template directory files.
$ sudo useradd --skel ${path-to-template_directory} --create-home ${username}
try on your machine

This command is used to create a new user on a Linux or Unix system with the given username and home directory. The sudo command is used to run the following command with administrative privileges. Here's a breakdown of the command:

  • sudo: This command is used in Unix-like operating systems to execute commands with administrative or root privileges.

  • useradd: This is a command used to create a new user account.

  • --skel ${path-to-template_directory}: This option is used to specify a template directory that will be used as a skeleton to populate the user's home directory with initial files and directories. The ${path-to-template_directory} needs to be replaced with the actual path to the directory you want to use as a template.

  • --create-home: This option is used to create the user's home directory. By default, the user's home directory is not created when using the useradd command.

  • ${username}: This is the username for the new user. It needs to be replaced with the desired username.

Overall, this command will create a new user with the specified username, create a home directory for the user, and populate it with files and directories from the template directory.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the useradd tool