Linux Manually add Users

Source: Internet
Author: User
Tags crypt

You can add users directly under Linux using Useradd, and we can also try to add users by editing/etc/passwd,/etc/group, and/etc/shadow files. The steps are as follows:

[[email protected] ~]# ID CentOS
Id:centos:No such user

Add CentOS users this time.

1. Vim/etc/group

Add a row

centos:x:508:

2. vim/etc/passwd

Add a row at the end

Centos:x:508:508::/home/centos:/bin/bash

3. Generate a MD5 value for a password with Grub-md5-crypt

[Email protected] home]# Grub-md5-crypt
Password:
Retype Password:
$1$fb3an$nyiggztvzws1xhcqvof5t.

4. Vim/etc/shadow

Add a row

Centos:$1$fb3an$nyiggztvzws1xhcqvof5t.:1664:0:99999:7:::

5. Initializing the user home directory with/etc/skel

Cp-r/etc/skel//home/centos

The specific features of/etc/skel can be found in the following blog posts http://blog.csdn.net/todd911/article/details/8299018

6. Also need to modify the directory permissions of/home/centos, only the user itself has full permissions to the directory, other users and groups have no permissions to this directory.

[Email protected] home]# Cd/home
[email protected] home]# LL
Total 950236
Drwxr-xr-x. 2 root root 4096 01:57 CentOS
DRWX------. 2 Gentoo gentoo 4096 01:49 Gentoo
-rw-r--r--. 1 root root 382955520 Jul 05:10 Linux-2.6.32.67.tar
-rw-r--r--. 1 root root 590069760 Jul 04:29 Linux-4.0.5.tar
[Email protected] home]# chmod-r go=---centos/
[Email protected] home]# chown-r Centos:centos centos/
[email protected] home]# LL
Total 950236
DRWX------. 2 CentOS centos 4096 01:57 CentOS
DRWX------. 2 Gentoo gentoo 4096 01:49 Gentoo
-rw-r--r--. 1 root root 382955520 Jul 05:10 Linux-2.6.32.67.tar
-rw-r--r--. 1 root root 590069760 Jul 04:29 Linux-4.0.5.tar

Detect whether to add success

[Email protected] home]# Su-centos
[Email protected] ~]$ pwd
/home/centos

[[email protected] home]# ID CentOS
uid=508 (CentOS) gid=508 (CentOS) groups=508 (CentOS)


This article is from the "My Technology Life" blog, make sure to keep this source http://duf0913.blog.51cto.com/6360025/1683159

Linux Manually add Users

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.