Linux (Radhat) Basic Learning-user management

Source: Internet
Author: User

1. User
用户就是系统使用者的身份在系统中用户存储为若干窜字符+若干个系统配置文件

User information involves the system configuration file:

/etc/passwd     ###用户信息用户:密码:uid:gid:说明:家目录:用户使用的shell

Root User:

Student Users:

/etc/shadow     ###用户认证信息用户:密码:最后一次密码修改该时间:最短有效期:最长有效期:警告期:非活跃期:帐号到期日

Root User:

Student Users:

/etc/group      ###组信息组名称:组密码:组id:附加组成员

Root

Student

/etc/gshadow        ###组认证信息/home/username      ###用户家目录/etc/skel/.*        ###用户骨架文件

Note:/etc/skel/All files or directories in this directory will be copied to the user's home directory during the user's new process
Hidden files that are default in this directory are the user's default profile

2. User Management

1. User Establishment

useradd     [参数]        用户名字                -u      指定用户uid                -g     指定用户初始组信息,这个组必须已经存在                -G    指定附加组,这个组必须存在                -c     用户说明                -d     用户家目录                -s      用户所使用的shell,/etc/shells记录了用户能使用shell的名字

2. User deletion and deletion

userdel     -r  用户名称                   -r表示删除用户信息及用户的系统配置

3. Establishment of User Group group

groupadd    [参数] 组名字          建立用户组                  -g     指定用户组gidgroupdel    组名字         删除用户组

Monitoring commands for the above experiments:

watch -n 1 ‘tail -n 3 /etc/passwd /etc/group;echo ====;ls -l /home;echo ===;ls -l /mnt‘

A. Create a new user Westos and user group Testgroup

B. Deleting a user Westos

C. Deleting a user group Testgroup

PS: Precautions

建立用户和用户组时,没有指定uid或gid,则默认从前一个uid/gid开始累加。在建立第一个用户或者用户组时没有指定其uid/gid,默认其值都是1001

4. User ID Information view

id  [参数]    用户    -u  ##用户uid    -g  ##用户初始组id    -G  ##用户所有所在组id    -n  ##显示名称而不是id数字    -a  ##显示所有信息


5. Changes to user information

usermod 参数  用户    -l       ##更改用户名称    -u     ##更改uid    -g     ##更改gid    -G    ##更改附加组    -aG ##添加附加组    -c     ##更改说明    -d     ##更改家目录指定    -md ##更改家目录指定及家目录名称    -s     ##更改ell    -L    ##冻结帐号    -U   ##解锁

6. User Password

passwd [参数] 用户名称                -S student                     ##用户密码信息                --status student            ##用户密码状态                -l student ##锁定帐号                -u student ##解锁                -n 1 student ##设定密码最短有效期                -x 30 student ##设定密码最长有效期                -w 3 student ##警告期                -i 2 student ##设定用户非活跃天数                -d student ##清除用户密码

Monitoring passwd Password Information

    watch -n 1 passwd -S student

3. User decentralization

1. In the system, Superuser can delegate actions that ordinary users cannot perform to ordinary users.

下放权力配置文件:/etc/sudoers

2. Ways of delegating authority

超级用户执行visudo进入编辑/etc/sudoers模式格式:        获得权限用户  主机名称=(获得到的用户身份) 命令栗子:test desktop0.example.com=(root) /usr/sbin/useradd            test用户能在desktop0.example.com以超级用户身份执行/usr/sbin/useradd,即添加用户的操作作

3. Commands for general users to perform delegated authority

sudo    命令     ##如果第一次执行sudo需要输入当前用户自己的帐号密码,在/etc/sudoers中如果设置如下:    test    desktop0.example.com=(root)     NOPASSWD: /usr/sbin/useradd    表示用户调用sudo命令的时候不需要自己密码
4. Control of user authentication information
chage 参数 用户              -d    ##用户密码组后一次修改的时间,如果设定成0,用户登陆系统后必须修改自己的密码              -m ##最短有效期             -M ##最长有效期             -W ##警告期              -I    ##用户非活跃天数             -E ##帐号到期日格式 -E "YYYY-MM-DD"
5. Root user password forgot how to deal with it?
1.重新启动系统2.在系统启动阶段按上下健停止系统系统引导3.选择启动引导标题,按“E”进行编辑4.找到linux16引导条目这一行,从这行最后删除到ro选项,并把ro改为rw,然后添加rd.break选项5.ctrl+x启动设定过后的系统引导条目6.进入系统后执行chroot /sysroot切换到真实的系统环境7.passwd root修改超级用户密码8.建立文件/.autorelabel让系统从新扫描所有文件9.exit两次使系统自动重新启动

Linux (Radhat) Basic Learning-user management

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.