zoukankan      html  css  js  c++  java
  • Linux系统管理上机作业3

    Chapter 04

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

    [root@localhost ~]# mkdir /guanli

    root@localhost ~]# cd /guanli

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

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

    [root@localhost guanli]# groupadd -g 2001 zonghe
    [root@localhost guanli]# groupadd -g 2002 caiwu
    [root@localhost guanli]# groupadd -g 2003 jishu
    [root@localhost guanli]# tail -3 /etc/group
    zonghe:x:2001:
    caiwu:x:2002:
    jishu:x:2003:

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

    [root@localhost guanli]# useradd jerry
    [root@localhost guanli]# useradd -e 2020-12-30 kylin
    [root@localhost guanli]# useradd tsengia
    [root@localhost guanli]# useradd obama
    [root@localhost guanli]# ls /home
    bbh jerry kylin obama tsengia

    4、将jerry、kylin、tsengia、obama等用户添加到zonghe组内

    [root@localhost guanli]# gpasswd -M jerry,kylin,tsengia,obama zonghe

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

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

    root@localhost ~]# tail -2 /etc/passwd
    handy:x:1005:1005::/home/handy:/bin/bash
    cucci:x:1006:1006::/home/cucci:/sbin/nologin

    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

    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: 操作成功
    [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-30 20:10 (:0)
    root pts/0 2019-07-31 08:25 (192.168.100.139)
    [root@localhost ~]# w
    11:24:30 up 3:59, 3 users, load average: 0.04, 0.06, 0.06
    USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
    root :0 :0 二20 ?xdm? 1:48 0.10s gdm-session-worker [pam/gdm-passw
    root pts/0 192.168.100.139 08:25 6.00s 0.18s 0.00s w
    root pts/1 192.168.100.139 11:24 6.00s 0.01s 0.01s -bash

    [root@localhost ~]# fuser -k /dev/pts/1
    /dev/pts/1: 5017

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

    [root@localhost ~]# groups cucci
    cucci : cucci jishu guanli
    [root@localhost ~]# finger cucci
    Login: cucci Name:
    Directory: /home/cucci Shell: /sbin/nologin
    Never logged in.
    No mail.
    No Plan.

    13、手工创建账号student

    [root@localhost ~]# vi /etc/passwd

    student:x:1007:1007::/home/student:/bin/bash

    [root@localhost ~]# vi /etc/shadow

    student:!!:18108:0:99999:7:::

    [root@localhost ~]# vi /etc/group

    student:x:1007:

    [root@localhost ~]# mkdir /home/student
    [root@localhost ~]# cp /etc/skel/.bash* /home/student
    [root@localhost ~]# passwd student
    更改用户 student 的密码 。
    新的 密码:
    无效的密码: 密码少于 8 个字符
    重新输入新的 密码:
    passwd:所有的身份验证令牌已经成功更新。
    [root@localhost ~]# vi ~student/.bash_profile

    [root@localhost ~]# mkdir /home/student
    [root@localhost ~]# cp /etc/skel/.bash* /home/student
    [root@localhost ~]# passwd student
    更改用户 student 的密码 。
    新的 密码:
    无效的密码: 密码少于 8 个字符
    重新输入新的 密码:
    passwd:所有的身份验证令牌已经成功更新。
    [root@localhost ~]# vi ~student/.bash_profile

    [root@localhost ~]# mkdir /home/student
    [root@localhost ~]# cp /etc/skel/.bash* /home/student

    [root@localhost ~]# vi ~student/.bash_profile

    echo"welcome student!"

    [root@localhost ~]# vi ~student/.bashrc

    echo "hi! this is a new bash!"

    [root@localhost ~]# vi ~student/.bash_logout
    echo "byebye student!"

    [root@localhost ~]# su student
    hi! this is a new bash!
    [student@localhost root]$ exit
    exit
    [root@localhost ~]#

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

    [root@localhost ~]# chown :guanli /guanli
    [root@localhost ~]# chown :zonghe /guanli/zonghe
    [root@localhost ~]# chown :jishu /guanli/jishu
    [root@localhost ~]# ll -d /guanli
    drwxr-xr-x 4 root guanli 31 7月 31 14:22 /guanli
    [root@localhost ~]# ll -d /guanli/zonghe
    drwxr-xr-x 2 root zonghe 6 7月 31 14:22 /guanli/zonghe
    [root@localhost ~]# ll -d /guanli/jishu
    drwxr-xr-x 2 root jishu 6 7月 31 14:22 /guanli/jishu

    [root@localhost ~]# chmod o-r /guanli/
    [root@localhost ~]# chmod o-r /guanli/zonghe/
    [root@localhost ~]# chmod o-r /guanli/jishu/

    15、建立公共目录/ceshi
    允许技术组内的所有用户读取、写入、执行文件
    禁止其他用户读、写、执行

    [root@localhost ~]# mkdir -m 777 /ceshi

    [root@localhost ~]# chown :jishu /ceshi
    [root@localhost ~]# chmod 777 /jishu

    [root@localhost ~]# chmod o-rwx /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用户的UID为8888

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

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

    [root@localhost ~]# passwd -x 60 kylin
    调整用户密码老化数据kylin。
    passwd: 操作成功

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

    [root@localhost ~]# id handy
    uid=1005(handy) gid=1005(handy) 组=1005(handy),2003(jishu),2004(guanli)
    [root@localhost ~]# groups handy
    handy : handy jishu guanli
    [root@localhost ~]# finger handy
    Login: handy Name:
    Directory: /home/handy Shell: /bin/bash
    Never logged in.
    No mail.
    No Plan.
    [root@localhost ~]# w handy
    14:57:58 up 7:32, 2 users, load average: 0.00, 0.01, 0.05
    USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT

  • 相关阅读:
    Intelligence System
    Hawk-and-Chicken
    The Stable Marriage Problem
    HDU 1173 采矿
    HDU 1018 Big Number 斯特林公式
    HDU 1005 Number Sequence
    ZOJ-3941 Kpop Music Party
    Codeforces 939 D Love Rescue
    Codefroces 939 C Convenient For Everybody
    Codeforces 935 C Fifa and Fafa
  • 原文地址:https://www.cnblogs.com/bbhymy/p/11274686.html
Copyright © 2011-2022 走看看