zoukankan      html  css  js  c++  java
  • chapter4作业

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

    [root@localhost ~]# mkdir -p /guanli/zonghe/ |mkdir -p /guanli/jishu/
    [root@localhost ~]# ls
    anaconda-ks.cfg httpd-2.2.17.tar.gz media 公共 模板 视频 图片 文档 下载 音乐 桌面
    [root@localhost ~]# ls -a
    . .bash_logout .config .ICEauthority .Xauthority 图片 桌面
    .. .bash_profile .cshrc .local 公共 文档
    anaconda-ks.cfg .bashrc .esd_auth media 模板 下载
    .bash_history .cache httpd-2.2.17.tar.gz .tcshrc 视频 音乐
    [root@localhost ~]# cd /guanli
    [root@localhost guanli]# ls
    jishu zonghe

    2、添加组帐号zonghe、caiwu、jishu,GID号分别设置为2001、2002、2003

    [root@localhost ~]# groupadd -g 2001 zonghe
    [root@localhost ~]# tail -3 /etc/group
    tcpdump:x:72:
    liu:x:1000:liu
    zonghe:x:2001:
    [root@localhost ~]# groupadd -g 2002 caiwu
    [root@localhost ~]# groupadd -g 2003 jushu
    [root@localhost ~]# tail -3 /etc/group
    zonghe:x:2001:
    caiwu:x:2002:
    jushu:x:2003:

    3、创建jerry、kylin、tsengia、obama用户,其中的kylin用户帐号在2020年12月30日后失效

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

    4、将jerry、kylin、tsengia、obama等用户添加到zonghe组内
    [root@localhost zonghe]# gpasswd -M jerry,kylin,obama,tsengia zonghe

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

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

    6、将handy、cucci等用户添加到jishu组内

    [root@localhost ~]# gpasswd -M handy,cucci jishu

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

    [root@localhost ~]# groupadd guanli
    [root@localhost ~]# gpasswd -M jerry,kylin,tsengia,obama,handy,cucci guanli
    [root@localhost ~]# tail -3 /etc/group
    handy:x:1005:
    cucci:x:1006:
    guanli:x:2004:jerry,kylin,tsengia,obama,handy,cucci

    8、将zonghe组内的obama用户删除

    [root@localhost ~]# gpasswd -d obama zonghe
    正在将用户“obama”从“zonghe”组中删除

    9、为jerry用户设置密码为“123456”(使用普通方法)
    为cucci用户设置密码为“redhat”(使用--stdin方法)

    [root@localhost ~]# passwd jerry
    更改用户 jerry 的密码 。
    新的 密码:
    无效的密码: 密码少于 8 个字符
    重新输入新的 密码:
    passwd:所有的身份验证令牌已经成功更新。

    [root@localhost ~]# echo "redhat" |passwd --stdin cucci
    更改用户 cucci 的密码 。
    passwd:所有的身份验证令牌已经成功更新。

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

    [root@localhost /]# passwd -l jerry
    锁定用户 jerry 的密码 。
    passwd: 操作成功

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

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

    [root@localhost ~]# groups cucci
    cucci : cucci guanli

    13、手工创建账号student

    [root@localhost ~]# useradd student

    14、设置权限及归属:
    /guanli目录属组设为guanli
    /guanli/zonghe目录的属组设为zonghe
    /guanli/jishu目录的属组设为jishu
    设置3个目录都是禁止其他用户访问的权限

    [root@localhost ~]# chown .jishu /guanli/jishu/
    [root@localhost ~]# chmod -R a-r /guanli
    [root@localhost ~]# ls -l /guanli/
    总用量 0
    d-wx--x--x. 2 root jishu 6 7月 30 19:21 jishu
    d-wx--x--x. 2 root zonghe 6 7月 30 19:21 zonghe
    [root@localhost ~]# ll -d /guanli/
    d-wx--x--x. 4 root guanli 31 7月 30 19:21 /guanli/
    [root@localhost ~]#

    15、建立公共目录/ceshi
    允许技术组内的所有用户读取、写入、执行文件
    禁止其他用户读、写、执行
    [root@localhost ~]# chmod o-rwx ceshi
    [root@localhost ~]# ll
    总用量 4
    -rw-------. 1 root root 1455 7月 29 17:02 anaconda-ks.cfg
    drwxrwx---. 2 root root 6 7月 30 12:05 ceshi
    drwxr-xr-x. 2 root root 6 7月 29 17:04 公共
    drwxr-xr-x. 2 root root 6 7月 29 17:04 模板
    drwxr-xr-x. 2 root root 6 7月 29 17:04 视频
    drwxr-xr-x. 2 root root 6 7月 29 17:04 图片
    drwxr-xr-x. 2 root root 6 7月 29 17:04 文档
    drwxr-xr-x. 2 root root 6 7月 29 17:04 下载
    drwxr-xr-x. 2 root root 6 7月 29 17:04 音乐
    drwxr-xr-x. 2 root root 6 7月 29 17:04 桌面
    [root@localhost ~]#

    16、清除jerry用户密码
    [root@localhost ~]# passwd -d jerry
    清除用户的密码 jerry。
    passwd: 操作成功
    [root@localhost ~]# passwd -y jerry
    passwd:错误的参数 -y:未知的选项
    [root@localhost ~]# passwd -S jerry
    jerry NP 2019-07-30 0 99999 7 -1 (密码为空。)
    [root@localhost ~]#

    17、锁定cucci用户密码并查看状态
    [root@localhost ~]# passwd -S jerry
    jerry NP 2019-07-30 0 99999 7 -1 (密码为空。)
    [root@localhost ~]# passwd -l cucci
    锁定用户 cucci 的密码 。
    passwd: 操作成功
    [root@localhost ~]# passwd -S cucci
    cucci LK 2019-07-30 0 99999 7 -1 (密码已被锁定。)

    18、修改obama用户的UID为8888
    [root@localhost ~]# usermod -u 888 obamam
    [root@localhost ~]# cat /etc/passwd |grep "obamam"
    obamam:x:888:1004::/home/obamam:/bin/bash
    19、通过passwd命令修改kylin用户的最长密码使用期限为60天
    [root@localhost ~]# passwd -i 30 kylin
    调整用户密码老化数据kylin。
    passwd: 操作成功
    20、通过id groups finger等命令查看用户handy信息
    [root@localhost ~]# id handy
    uid=1005(handy) gid=1005(handy) 组=1005(handy)
    [root@localhost ~]# groups handy
    handy : handy
    [root@localhost ~]# finger handy
    Login: handy Name:
    Directory: /home/handy Shell: /bin/bash
    Never logged in.
    No mail.
    No Plan.

  • 相关阅读:
    软件工程概论第十二周学习进度
    冲刺第十天
    评价搜狗输入法
    冲刺第九天
    冲刺第八天
    冲刺第七天
    冲刺第六天
    冲刺第五天
    软件工程概论第十一周学习进度
    冲刺第四天
  • 原文地址:https://www.cnblogs.com/liu1584712/p/11274188.html
Copyright © 2011-2022 走看看