第三週做業

一、顯示/etc目錄下,以非字母開頭,後面跟了一個字母以及其它任意長度任意字符的文件或目錄

 

[root@centos7 etc]#ls /etc/[^a-z][a-z]*
/etc/1abd  /etc/1aljlkd
/etc/9jjj:

二、複製/etc目錄下全部以p開頭,以非數字結尾的文件或目錄到/tmp/mytest1目錄中。

cp -r  /etc/p*[^0-9] //tmp/mytest1

三、將/etc/issue文件中的內容轉換爲大寫後保存至/tmp/issue.out文件中

 

[root@centos7 etc]#tr '[:lower:]' '[:upper:]' </etc/issue >/tmp/issue.out
[root@centos7 etc]#cat /tmp/issue.out 
\S
KERNEL \R ON AN \M

 

四、請總結描述用戶和組管理類命令的使用方法並完成如下練習:

 

   (1)、建立組distro,其GID爲2019;linux

[root@centos7 data]#groupadd -g 2019 distro
[root@centos7 data]#getent group distro
distro:x:2019:

 

   (2)、建立用戶mandriva, 其ID號爲1005;基本組爲distro;shell

 

[root@centos7 data]#useradd -u 1005 -g distro mandriva
[root@centos7 data]#id mandriva
uid=1005(mandriva) gid=2019(distro) groups=2019(distro)

   (3)、建立用戶mageia,其ID號爲1100,家目錄爲/home/linux;centos

[root@centos7 home]#useradd -u 1100 -d /home/linux/ mageia
[root@centos7 home]#cat /etc/passwd |grep mageia
mageia:x:1100:1100::/home/linux/:/bin/bash

 (4)、給用戶mageia添加密碼,密碼爲mageedu,並設置用戶密碼7天后過時bash

[root@centos7 scripts43]#echo "mageedu" |passwd --stdin  mageia
Changing password for user mageia.
passwd: all authentication tokens updated successfully.
[root@centos7 scripts43]#passwd -x 7 mageia
Adjusting aging data for user mageia.
passwd: Success

[root@centos7 scripts43]#getent shadow mageia                 
mageia:$6$EHK3DrD3$c9ELy/xJyLTAf8IqLzF627f5qxlV/4rndN1tmh0HlRgaman5QhVF6UBAgVm.o8sOHr6gyUrldcRHIBUMW/uk71:18240:0:7:7:::

   (5)、刪除mandriva,但保留其家目錄;ide

[root@centos7 home]#userdel mandriva
[root@centos7 home]#ls -d /home/mandriva
/home/mandriva

 

   (6)、建立用戶slackware,其ID號爲2002,基本組爲distro,附加組peguin;ui

[root@centos7 data]#useradd -g distro -u 2002 -G peguin slackware
[root@centos7 data]#id slackware
uid=2002(slackware) gid=2019(distro) groups=2019(distro),2020(peguin)
[root@centos7 data]#

   (7)、修改slackware的默認shell爲/bin/tcsh;加密

 

[root@centos7 home]#cat /etc/passwd |grep slackware
slackware:x:2002:2019::/home/slackware:/bin/bash
[root@centos7 home]#usermod -s /bin/tcsh slackware
[root@centos7 home]#cat /etc/passwd |grep slackware
slackware:x:2002:2019::/home/slackware:/bin/tcsh

   (8)、爲用戶slackware新增附加組admins;centos7

usermod -a  slackware -G admins
[root@centos7 home]#groupmems  -a slackware -g admins 
[root@centos7 home]#groupmems  -l -g admins
slackware 
[root@centos7 home]#id slackware
uid=2002(slackware) gid=2019(distro) groups=2019(distro),2020(peguin),2021(admins)

用戶和組管理類命令總結

第三週做業

相關文章
相關標籤/搜索