美文网首页
【马哥教育】N43作业-003

【马哥教育】N43作业-003

作者: 亦然自得 | 来源:发表于2019-12-15 19:18 被阅读0次

自我学习笔记003

1、显示/etc目录下,以非字母开头,后面跟了一个字母以及其它任意长度任意字符的文件或目录

[root@Pandj home]# ls -a /etc/ |egrep ^[^[:alpha:]][[:alpha:]].*
.pwd.lock
.updated
[root@Pandj home]#

2、复制/etc目录下所有以p开头,以非数字结尾的文件或目录到/tmp/mytest1目录中。

[root@Pandj home]# mkdir /tmp/mytest1
[root@Pandj home]# cp -a /etc/p*[a-z] /tmp/mytest1/
[root@Pandj home]# ls -a /tmp/mytest1
.  ..  pam.d  passwd  pki  plymouth  pm  popt.d  postfix  ppp  prelink.conf.d  printcap  profile  profile.d  protocols  python
[root@Pandj home]# 

3、将/etc/issue文件中的内容转换为大写后保存至/tmp/issue.out文件中

[root@Pandj home]# cat /etc/issue
\S
Kernel \r on an \m

[root@Pandj home]# cat /etc/issue|tr -s [[:lower:]] [[:upper:]] >/tmp/issue.out
[root@Pandj home]# cat /tmp/issue.out 
\S
KERNEL \R ON AN \M

[root@Pandj home]# 

4、请总结描述用户和组管理类命令的使用方法并完成以下练习:

(1)、创建组distro,其GID为2019;

[root@Pandj home]# groupadd distro -g 2019

(2)、创建用户mandriva, 其ID号为1005;基本组为distro;

[root@Pandj home]# useradd -u 1005 -g distro mandriva
[root@Pandj home]# id mandriva
uid=1005(mandriva) gid=2019(distro) groups=2019(distro)
[root@Pandj home]# getent passwd|grep mandriva
mandriva:x:1005:2019::/home/mandriva:/bin/bash
[root@Pandj home]# 

(3)、创建用户mageia,其ID号为1100,家目录为/home/linux;

[root@Pandj home]# useradd -u 1100 -d /home/linux mageia
[root@Pandj home]# id mageia
uid=1100(mageia) gid=1100(mageia) groups=1100(mageia)
[root@Pandj home]# cat /etc/passwd |grep mageia
mageia:x:1100:1100::/home/linux:/bin/bash
[root@Pandj home]# 

(4)、给用户mageia添加密码,密码为mageedu,并设置用户密码7天后过期

[root@Pandj home]# echo mageedu |passwd --stdin mageia
Changing password for user mageia.
passwd: all authentication tokens updated successfully.
[root@Pandj home]# usermod -e `date -d 1weeks +%F` mageia
[root@Pandj home]# getent shadow mageia
mageia:$6$Hsk.kcgo$I1IaTEhzJHhbyMTiLjd0bQOgEaVLes1iznRVFlXA3zlNqQ/7lTa4SZRT9AinBCwCHxPRVnHGz9L0Uf8I2Sg4X0:18245:0:99999:7::18252:
[root@Pandj home]# 

(5)、删除mandriva,但保留其家目录;

[root@Pandj home]# id mandriva
uid=1005(mandriva) gid=2019(distro) groups=2019(distro)
[root@Pandj home]# userdel mandriva
[root@Pandj home]# ls /home/
linux  mandriva  mysite  pandj.py  pandj.py.link1  pandj.py.link2
[root@Pandj home]# 

(6)、创建用户slackware,其ID号为2002,基本组为distro,附加组peguin;

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

(7)、修改slackware的默认shell为/bin/tcsh;

[root@Pandj home]# getent passwd slackware
slackware:x:2002:2019::/home/slackware:/bin/bash
[root@Pandj home]# usermod -s /bin/tcsh slackware
[root@Pandj home]# getent passwd slackware
slackware:x:2002:2019::/home/slackware:/bin/tcsh
[root@Pandj home]#

(8)、为用户slackware新增附加组admins;

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

相关文章

网友评论

      本文标题:【马哥教育】N43作业-003

      本文链接:https://www.haomeiwen.com/subject/durlnctx.html