Linux Useradd-userdel (add an account and delete an account)

Source: Internet
Author: User

    1. Add account

Command: Useradd

Syntax: useradd [-u UID] [-G GID] [-D HOME] [-M] [-S]

'-U ' custom UID

'-G ' makes it belong to a group that already exists, followed by the group ID, or with the group name

'-d ' Customize user's home directory

'-M ' does not create a home directory

'-s ' custom shell

[Email protected] ~]# useradd test10[[email protected] ~]# tail-n1/etc/passwdtest10:x:500:503::/home/test10:/bin/ Bash[[email protected] ~]# tail-n1/etc/grouptest10:x:503:

' Useradd ' does not add any options directly to the username, it creates a group with the same name as the user name.

[Email protected] ~]# useradd-u510-g 513-m-s/sbin/nologin user11useradd:group ' 513 ' does not exist[[email protected ] ~]# useradd-u510-g 502-m-s/sbin/nologin user11[[email protected] ~]# useradd-u511-g grptest1 user12[[email Protec Ted] ~]# tail-n2/etc/passwduser11:x:510:502::/home/user11:/sbin/nologinuser12:x:511:502::/home/user12:/bin/bash[ [Email protected] ~]# tail-n2/etc/groupgrptest1:x:502:test10:x:503:

The '-G ' option is followed by a non-existent GID error indicating that the group does not exist. Just said that the '-m ' option plus does not create a user home directory, but still has this field in the/etc/passwd file. However, if you use ls /home/user11 , you will be prompted to see that the directory does not exist. So the '-m ' option only works by not creating that directory.

[[email protected] ~]# Ls/home/user11ls: Unable to access/home/user11: No file or directory
    1. Delete Account

Command: Userdel

Syntax: userdel [-r] username

[[email protected] ~]# ls-ld/home/user12drwx------3 user12 grptest1 4096 May 07:12/home/user12[[email protected] ~] # Userdel User12[[email protected] ~]# ls-ld/home/user12drwx------3 511 grptest1 4096 May 07:12/home/user12[[email Protected] ~]# ls-ld/home/test10/drwx------3 test10 test10 4096 May 07:09/home/test10/[[email protected] ~]# Userde L-r Test10[[email protected] ~]# Ls-ld/home/test10/ls: Unable to access/home/test10/: No file or directory

The '-r ' option has only one function, which is to delete the account with the home directory when it is deleted.


This article is from "Linux rookie" blog, please be sure to keep this source http://490617581.blog.51cto.com/11186315/1757788

Linux Useradd-userdel (add an account and delete an account)

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.