zoukankan      html  css  js  c++  java
  • Linux系统管理第三次作业 账号管理 权限及归属管理

    1创建/guanli 目录,在/guanli下创建zonghe jishu 两个目录(一条命令)

    [root@localhost ~]# mkdir /guanli

    [root@localhost ~]# mkdir /guanli/zonghe | mkdir /guanli/jishu

    [root@localhost ~]# ls /guanli

    jishu  zonghe

    2添加组帐号zonghecaiwujishuGID号分别设置为200120022003

    [root@localhost ~]# groupadd -g 2001 zonghe

    [root@localhost ~]# groupadd -g 2002 caiwu

    [root@localhost ~]# groupadd -g 2003 jishu

    3创建jerrykylintsengiaobama用户,其中的kylin用户帐号在20201230日后失效

    [root@localhost ~]# useradd jerry

    [root@localhost ~]# useradd -e 2020-12-30 kylin

    [root@localhost ~]# useradd tsengia

    [root@localhost ~]# useradd obama

    4jerrykylintsengiaobama等用户添加到zonghe组内

    [root@localhost ~]# gpasswd -a jerry zonghe

    正在将用户jerry”加入到“zonghe”组中

    [root@localhost ~]# gpasswd -a kylin zonghe

    正在将用户kylin”加入到“zonghe”组中

    [root@localhost ~]# gpasswd -a tsengia zonghe

    正在将用户tsengia”加入到“zonghe”组中

    [root@localhost ~]# gpasswd -a obama zonghe

    正在将用户obama”加入到“zonghe”组中

    5创建handycucci用户,其中cucci帐号的登录Shell设置为“/sbin/nologin

    [root@localhost ~]# useradd -s /sbin/nologin cucci

    6handycucci等用户添加到jishu组内

    [root@localhost ~]# gpasswd -a handy jishu

    正在将用户handy”加入到“jishu”组中

    [root@localhost ~]# gpasswd -a cucci jishu

    正在将用户cucci”加入到“jishu”组中

    7将上述的所有用户均要求加入到guanli组内

    [root@localhost ~]# gpasswd -M jerry,kylin,tsengia,obama,handy,cucci guanli

    [root@localhost ~]# tail -6 /etc/group

    jerry:x:2006:

    kylin:x:1003:

    tsengia:x:1004:

    obama:x:1005:

    handy:x:1006:

    cucci:x:1007:

    8zonghe组内的obama用户删除

    [root@localhost ~]# gpasswd -d obama zonghe

    正在将用户obama”从“zonghe”组中删除

    9jerry用户设置密码为“123456”(使用普通方法)

       cucci用户设置密码为“redhat”(使用--stdin方法)  

    [root@localhost ~]# passwd jerry

    更改用户 jerry 的密码 。

    新的 密码:

    无效的密码: 密码少于 8 个字符

    重新输入新的 密码:

    passwd:所有的身份验证令牌已经成功更新。

    [root@localhost ~]# echo "redhat" | passwd --stdin cucci

    更改用户 cucci 的密码 。

    passwd:所有的身份验证令牌已经成功更新。

    10jerry用户锁定,并查看锁定状态

    [root@localhost ~]# passwd -l jerry

    锁定用户 jerry 的密码 。

    passwd: 操作成功

    [root@localhost ~]# passwd -S jerry

    jerry LK 2019-07-31 0 99999 7 -1 (密码已被锁定。)

    11打开两个xshell窗口,通过(who 或者 w)命令查看连接状态,并通过fuser杀掉其中一个

    [root@localhost ~]# who

    root     :0           2019-07-31 08:21 (:0)

    root     pts/0        2019-07-31 08:22 (:0)

    root     pts/1        2019-07-31 08:22 (192.168.100.142)

    root     pts/2        2019-07-31 09:10 (192.168.100.142)

    [root@localhost ~]# fuser -k /dev/pts/0

    /dev/pts/0:           2615  2622

    [root@localhost ~]# who

    root     :0           2019-07-31 08:21 (:0)

    root     pts/1        2019-07-31 08:22 (192.168.100.142)

    root     pts/2        2019-07-31 09:10 (192.168.100.142)

    12查看cucci用户,属于那些组,并查看其详细信息

    [root@localhost ~]# finger cucci

    Login: cucci           Name:

    Directory: /home/cucci               Shell: /sbin/nologin

    Last login 731 09:15 (CST) on :1

    No mail.

    No Plan.

    [root@localhost ~]# groups cucci

    cucci : cucci guanli jishu

    13手工创建账号student

    vi /etc/passwd

    [root@localhost ~]# tail -2 /etc/passwd

    cucci:x:1007:1007::/home/cucci:/sbin/nologin

    student:x:1008::1008::/home/student:/bin/bash

    vi /etc/shadow

    [root@localhost ~]# tail -2 /etc/shadow

    cucci:$6$ou2dNTQH$jpaKVsi/F6Ycg7n9QIhkbYGckmK6hbLtMGjnY3ksXvmMf6dQrtputgX9GH4YQMXQOdMlHXuE.NHGXhaIIDMyz1:18108:0:99999:7:::

    student:!!:18109:0:99999:7:::

     vi /etc/group

    [root@localhost ~]# tail -2 /etc/group

    cucci:x:1007:

    student:x:1008:

    [root@localhost ~]# cd /home/student/

    [root@localhost ~]# su student

    [student@localhost root]$

    14设置权限及归属:

       /guanli目录属组设为guanli

    [root@localhost ~]# chown :guanli /guanli

       /guanli/zonghe目录的属组设为zonghe

    [root@localhost ~]# chown :zonghe /guanli/zonghe

       /guanli/jishu目录的属组设为jishu

    [root@localhost ~]# chown :jishu /guanli/jishu

       设置3个目录都是禁止其他用户访问的权限

    [root@localhost ~]# chmod -R o-rwx /guanli

    [root@localhost ~]# chmod -R o-rwx /guanli/zonghe

    [root@localhost ~]# chmod -R o-rwx /guanli/jishu

    15建立公共目录/ceshi

       允许技术组内的所有用户读取、写入、执行文件

       禁止其他用户读、写、执行

    [root@localhost ~]# chmod g=rwx /ceshi/

    [root@localhost ~]# ls -ld /ceshi/

    drwxrwxr-x. 2 root jishu 6 7月  31 10:25 /ceshi/

    [root@localhost ~]# chmod o-rwx /ceshi/

    [root@localhost ~]# ls -ld /ceshi/

    drwxrwx---. 2 root jishu 6 7月  31 10:25 /ceshi/

    16清除jerry用户密码

    [root@localhost ~]# passwd -d jerry

    清除用户的密码 jerry

    passwd: 操作成功

    17锁定cucci用户密码并查看状态

    [root@localhost ~]# passwd -l cucci

    锁定用户 cucci 的密码 。

    passwd: 操作成功

    [root@localhost ~]# passwd -S cucci

    cucci LK 2019-07-31 0 99999 7 -1 (密码已被锁定。)

    18修改obama用户的UID8888

    [root@localhost ~]# usermod -u 8888 obama

    obama:x:8888:1005::/home/obama:/bin/bash

    19通过passwd命令修改kylin用户的最长密码使用期限为60

    [root@localhost ~]# passwd -x 60 kylin

    调整用户密码老化数据kylin

    passwd: 操作成功

    [root@localhost ~]# grep kylin /etc/shadow

    kylin:!!:18107:0:60:7::18626:

    20、通过id groups finger等命令查看用户handy信息

    [root@localhost ~]# id handy

    uid=1006(handy) gid=1006(handy) =1006(handy),2005(guanli),2003(jishu)

    [root@localhost ~]# groups kylin

    kylin : kylin guanli zonghe

    [root@localhost ~]#

    [root@localhost ~]# finger kylin

    Login: kylin           Name:

    Directory: /home/kylin               Shell: /bin/bash

    Never logged in.

    No mail.

    No Plan.

  • 相关阅读:
    android状态栏
    python基础(二)——文件操作
    python基础(一)——字符串
    每日读书
    gradle相关
    EditText整体hint
    java生成pdf
    Androidstudio点9图报错
    【ASP.NET Core学习】使用JWT认证授权
    数据访问仓储模式的事务管理(Unit of Work)
  • 原文地址:https://www.cnblogs.com/ZCQ123456/p/11275329.html
Copyright © 2011-2022 走看看