Linux system Add, create new user commands and steps

Source: Internet
Author: User


Adding new users to Linux, creating new users, creating new accounts

Add User Group

sudo groupadd groupname
Add user

sudo useradd username-m-s/sbin/nologin-d/home/username-g groupname
-s/sbin/nologin settings can not log-s/bin/false (old method) also OK
-D Set User home directory
-G user Group
-M Create user Directory
The specific parameters of Useradd are

[root@317304 ~]# Useradd--help
Usage:useradd [Options] LOGIN

Options:
-B,--base-dir base_dir base directory for the home directory of the
New Account
-C,--comment comment GECOS field of the new account
-D,--home-dir home_dir home directory of the new account
-D,--defaults print or change default Useradd configuration
-E,--expiredate expire_date expiration DATE of the new account
-F,--inactive inactive password inactivity period of the new account
-G,--gid group name or ID of the primary group of the new
Account
-G,--groups groups list of supplementary groups of the new
Account
-H,--help display this help message and exit
-K,--skel Skel_dir Use this alternative skeleton directory
-K,--key key=value override/etc/login.defs defaults
-L,--no-log-init do don't add the user to the Lastlog and
Faillog databases
-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 don't create a group with the same name as
The user
-O,--non-unique allow to create the users with duplicate
(Non-unique) Uid
-p,--password password encrypted password of the new account
-R,--system create a System account
-S,--shell Shell login shell of the new account
-U,--uid uid user ID of the new account
-U,--user-group create a group with the same name as the user
-Z,--selinux-user seuser use a specific seuser for the SELinux user mapping
Change user logon rights

After adding the-s/sbin/nologin parameter, then this account cannot log in, if want to restore login to use

sudo usermod-s/bin/bash username

Disable user logon rights

sudo usermod-s/sbin/nologin username

Set Password

Set a password for the user so that the account can be used.

sudo passwd username

Delete User

sudo userdel username

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.