How to Use Adduser Command in Linux to Create a New User Account
The Adduser Command is a commonly used command in Linux that allows a user to add additional users to the system. The command is powerful and versatile, allowing the administrator to configure user accounts in a variety of ways. This article will provide an overview of the Adduser command and its various options.
Syntax and Usage:
The basic syntax to use the Adduser command is as follows:
adduser [options] username
Where 'username' is the name of the user to be added and 'options' are any additional parameters that can be used to customize user account settings. These options may include things like the user's home directory, primary group, shell, etc.
Options:
The following options are available when using the Adduser command:
- --home DIR: Specifies the user's home directory.
- --shell SHELL: Specifies the user's login shell.
- --no-create-home: Does not create the user's home directory.
- --uid UID: Set the user's UID.
- --gid GID: Set the user's primary group ID.
- --groups GROUP1[,GROUP2,...[,GROUPN]]: Set the user's supplementary groups.
- --system: Create a system account.
- --password PASSWORD: Set the user's password.
- --expiredate EXPIRE_DATE: Set the date on which the user account will expire.
- --help: Show help for the command.
Examples:
To add a new user with the name 'john' to the system with a home directory of 'johns_home', a primary group of 'users', and a shell of '/bin/bash', use the following command:
adduser --home johns_home --shell /bin/bash john
To add a new user with the name 'jane' which is a system account and has the UID 1000, use the following command:
adduser --system --uid 1000 jane
This article provided a brief overview of the Adduser command and its various options. For more information on this command, please refer to the man page.