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

[root@txcentos7 etc]# touch 15[root@txcentos7 etc]# touch 1aa[root@txcentos7 etc]# ls -d /etc/[^[:alpha:]][[:alpha:]]*/etc/1a  /etc/1aa

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

[root@txcentos7 tmp]# cp -a /etc/p*[^0-9] /tmp/mytest1/[root@txcentos7 tmp]# ls /tmp/mytest1/pam.d   passwd-  plymouth  popt.d   ppp             printcap  profile.d  pythonpasswd  pki      pm        postfix  prelink.conf.d  profile   protocols

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

[root@txcentos7 tmp]# cat /etc/issue | tr "a-z" "A-Z" >>/tmp/ussue.out[root@txcentos7 tmp]# cat /tmp/ussue.out\SKERNEL \R ON AN \M

4、请总结描述用户和组管理类命令的使用方法并完成以下练习:
(1)、创建组distro,其GID为2019;

[root@txcentos7.6 /root]groupadd -g 2019 distro

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

[root@txcentos7.6 /root]useradd mandriva -u 1015 -g distro[root@txcentos7.6 /root]cat /etc/passwd |egrep mandrivamandriva:x:1015:2019::/home/mandriva:/bin/bash[root@txcentos7.6 /root]groups mandrivamandriva : distro

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

[root@txcentos7 ~]# useradd mageia -d /home/linux -u 1100[root@txcentos7 ~]# cat /etc/passwd |egrep mageiamageia:x:1100:1100::/home/linux:/bin/bash[root@txcentos7 home]# ls /homelinux  mandriva  tommy  tt  username  wang  wang1  wwwww

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

[root@txcentos7 home]# echo mageedu | passwd --stdin  mageiaChanging password for user mageia.passwd: all authentication tokens updated successfully.[root@txcentos7 home]# passwd mageia -x 7Adjusting aging data for user mageia.passwd: Success#列出密码有效期:[root@txcentos7 home]# chage -l mageiaLast password change                                    : Mar 22, 2021Password expires                                        : Mar 29, 2021Password inactive                                       : neverAccount expires                                         : neverMinimum number of days between password change          : 0Maximum number of days between password change          : 7Number of days of warning before password expires       : 7

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

[root@txcentos7 home]# userdel mageia

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

[root@txcentos7 home]# groupadd peguin[root@txcentos7 home]# useradd slackware -u 2002 -g distro -G peguin[root@txcentos7 home]# groups slackwareslackware : distro peguin

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

[root@txcentos7 home]# usermod -s /bin/tcsh slackware[root@txcentos7 home]# cat /etc/passwd | egrep slackwareslackware:x:2002:2019::/home/slackware:/bin/tcsh

(8)、为用户slackware新增附加组admins,并设置不可登陆。

[root@txcentos7 home]# id  slackwareuid=2002(slackware) gid=2019(distro) groups=2019(distro),2020(peguin),2021(admins)[root@txcentos7 sbin]# usermod slackware -s /sbin/nologin[root@txcentos7 sbin]# echo mageedu | passwd --stdin slackwareChanging password for user slackware.passwd: all authentication tokens updated successfully.WARNING! The remote SSH server rejected X11 forwarding request.Last login: Mon Mar 22 22:02:57 2021 from 111.196.233.254This account is currently not available.Connection closing...Socket close.Connection closed by foreign host.

5、创建用户user1、user2、user3。在/data/下创建目录test

(1)、目录/data/test属主、属组为user1

[root@txcentos7 data]# chown user1:user1 test[root@txcentos7 data]# ll -ttotal 28drwxr-xr-x 2 user1 user1 4096 Mar 22 22:05 test

(2)、在目录属主、属组不变的情况下,user2对文件有读写权限

[root@txcentos7 data]# chmod o+rw test[root@txcentos7 data]# ll -ttotal 28drwxr-xrwx 2 user1 user1 4096 Mar 22 22:05 test[root@txcentos7 data]# su user2[user2@txcentos7 data]$ cd /data/[user2@txcentos7 data]$ ls1111  laji  lajixiang  nianling.txt  script  test  vkokdfs[user2@txcentos7 data]$ cd test/[user2@txcentos7 test]$ touch 10.txt[user2@txcentos7 test]$ lltotal 0-rw-rw-r-- 1 user2 user2 0 Mar 22 22:11 10.txt

(3)、user1在/data/test目录下创建文件a1.sh, a2.sh, a3.sh, a4.sh,设置所有用户都不可删除1.sh,2.sh文件、除了user1及root之外,所有用户都不可删除a3.sh, a4.sh

[user1@txcentos7 test]$ touch a{1..4}\.sh[user1@txcentos7 test]$ lsa1.sh  a2.sh  a3.sh  a4.sh设置所有用户不可删除时普通用户无法执行cahttr +i命令,是否有其他方法?[root@txcentos7 test]# chattr +i a1.sh[root@txcentos7 test]# chattr +i a2.sh[root@txcentos7 test]# lsattr-------------e-- ./a3.sh-------------e-- ./a4.sh----i--------e-- ./a1.sh----i--------e-- ./a2.sh

(4)、user3增加附加组user1,同时要求user1不能访问/data/test目录及其下所有文件

[root@txcentos7 test]# usermod user3 -aG user1[root@txcentos7 test]# id user3uid=2006(user3) gid=2006(user3) groups=2006(user3),2004(user1)setfacl -m u:user1:- /data/test/[root@txcentos7 test]# su user1[user1@txcentos7 test]$ cd /data/test/bash: cd: /data/test/: Permission denied


(5)、清理/data/test目录及其下所有文件的acl权限

[root@txcentos7 test]# setfacl -R -b /data/test/


©著作权归作者所有:来自51CTO博客作者qq604db53b5fadb的原创作品,如需转载,请注明出处,否则将追究法律责任

更多相关文章

  1. 高性能、高可用平台架构的演变过程
  2. Mybatis【2】-- 多个mapper文件以及namespace作用
  3. 如何将照片从数码相机导入到苹果Mac上的特定文件夹?
  4. 索刻科技CRM用户手册
  5. Safari 浏览器中自动填充用户名和密码功能介绍
  6. 分区出现“属性0字节”情况下的文件找回办法
  7. 公有云和超算中心对比,高性能计算用户选哪个好?
  8. Rancher面板权限配置
  9. Excelize -Go 开源项目中唯一支持复杂样式 XLSX 文件的类库

随机推荐

  1. android:launchMode="singleTask" 与 onN
  2. Android大图轮播-学习笔记
  3. Android Studio与HttpClient
  4. Android程序有很多Activity,在B中如何关闭
  5. Android App 如何动态加载类
  6. android 使用基站 wifi定位
  7. Android全屏与非全屏问题
  8. Android Studio 第六十五期 - Android业
  9. Android开发之Android的原生库
  10. Android(安卓)L为什么不用Android(安卓)5