adduser [options] username Linux Commands – Overview with Examples and FAQs

Introduction

The Linux command adduser is used to add a new user to the system. It is a simple command that can be used to quickly add a new user to the system with a few options. This command can be used to create a new user with a specific username, set the user’s password, and assign the user to a specific group. It can also be used to set the user’s home directory, shell, and other options. This command is a great way to quickly add a new user to the system without having to manually create the user.

Examples

The adduser command is used to add a new user to the system. It is used to create a new user account with the specified username.

Syntax:
adduser [options] username

Options:
-c, –comment COMMENT: Set the user’s GECOS field to COMMENT.
-d, –home HOME_DIR: Set the user’s home directory to HOME_DIR.
-e, –expiredate EXPIRE_DATE: Set the account expiration date to EXPIRE_DATE.
-f, –inactive INACTIVE: Set the number of days after a password expires until the account is permanently disabled.
-g, –gid GROUP: Set the user’s initial group to GROUP.
-G, –groups GROUPS: Set the user’s additional groups to GROUPS.
-k, –skel SKEL_DIR: Use SKEL_DIR as the skeleton directory.
-m, –create-home: Create the user’s home directory.
-M, –no-create-home: Do not create the user’s home directory.
-N, –no-user-group: Do not create a group with the same name as the user.
-p, –password PASSWORD: Set the user’s password to PASSWORD.
-r, –system: Create a system account.
-s, –shell SHELL: Set the user’s login shell to SHELL.
-u, –uid UID: Set the user’s UID to UID.

Example:
To add a new user with the username “john” and the password “password”, the command would be:

adduser -p password john


The adduser command in Linux is used to add a new user to the system. It is a simple and easy to use command that allows you to quickly add a new user to the system. The command has several options that can be used to customize the user’s account.

The basic syntax for the adduser command is:

adduser [options] username

The options available for the adduser command are:

  • -c : This option allows you to specify a comment for the user’s account. This comment is usually used to provide a brief description of the user.
  • -d : This option allows you to specify the home directory for the user. If this option is not specified, the user’s home directory will be set to the default location.
  • -e : This option allows you to specify the expiration date for the user’s account. If this option is not specified, the user’s account will never expire.
  • -g : This option allows you to specify the primary group for the user. If this option is not specified, the user will be added to the default group.
  • -G : This option allows you to specify additional groups for the user. This option can be used to add the user to multiple groups.
  • -m : This option allows you to specify whether or not to create the user’s home directory. If this option is not specified, the user’s home directory will be created.
  • -s : This option allows you to specify the shell for the user. If this option is not specified, the user will be assigned the default shell.
  • -u : This option allows you to specify the user ID for the user. If this option is not specified, the user ID will be automatically assigned.

The adduser command is a simple and easy to use command that allows you to quickly add a new user to the system. By using the various options available, you can customize the user’s account to meet your needs.


Discover more from Jassweb

Subscribe to get the latest posts sent to your email.

Jaspreet Singh Ghuman

Jaspreet Singh Ghuman

Jassweb.com/

Passionate Professional Blogger, Freelancer, WordPress Enthusiast, Digital Marketer, Web Developer, Server Operator, Networking Expert. Empowering online presence with diverse skills.

jassweb logo

Jassweb always keeps its services up-to-date with the latest trends in the market, providing its customers all over the world with high-end and easily extensible internet, intranet, and extranet products.

Contact
San Vito Al Tagliamento 33078
Pordenone Italy
Item added to cart.
0 items - 0.00