温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

linux文件管理与用户管理命令的用法

发布时间:2020-05-29 17:53:23 来源:亿速云 阅读:222 作者:鸽子 栏目:系统运维

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

[root@centos7 etc]# ls -d /etc/[^[:alpha:]][:alpha:]*

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

[root@centos7 etc]# mkdir /tmp/mytest1 && cp -a /etc/[p]*[^[:digit:]] /tmp/mytest1/
[root@centos7 etc]# ls /tmp/mytest1/  #查看结果
pam.d   passwd-       pinforc  plymouth  pnm2ppa.conf  postfix  prelink.conf.d  profile    protocols  purple
passwd  pbm2ppa.conf  pki      pm        popt.d        ppp      printcap        profile.d  pulse      python

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

[root@centos7 etc]# tr 'a-z' 'A-Z' < /etc/issue >/tmp/issue.out
[root@centos7 etc]# cat /tmp/issue.out  查看内容
\S
KERNEL \R ON AN \M

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

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

[root@centos7 etc]# groupadd distro -g 2019
[root@centos7 etc]# getent group distro #验证distro的GID
distro:x:2019:

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

[root@centos7 etc]# useradd mandriva -u 1005 -g distro
[root@centos7 etc]# id mandriva  #验证mandriva的UID号和基本组
uid=1005(mandriva) gid=2019(distro) groups=2019(distro)

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

[root@centos7 etc]# useradd mageia -u 1100 -d /home/linux
[root@centos7 etc]# getent passwd mageia  #验证结果
mageia:x:1100:1100::/home/linux:/bin/bash

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

[root@centos7 etc]# echo "mageedu" | passwd mageia --stdin -x 7
[root@centos7 etc]# getent shadow mageia  #验证结果
mageia:!!:18308:0:7:7:::

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

[root@centos7 etc]# userdel mandriva
[root@centos7 etc]# ls /home/  #验证结果 mandriva目录依旧存在
diyoujia  linux  mandriva  slackware  test

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

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

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

[root@centos7 etc]# chsh slackware -s /bin/tcsh
[root@centos7 etc]# getent passwd slackware  #验证结果
slackware:x:2002:2019::/home/slackware:/bin/tcsh

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

[root@centos7 etc]# usermod slackware -aG admins
[root@centos7 etc]# id slackware  #验证结果
uid=2002(slackware) gid=2019(distro) groups=2019(distro),2020(peguin),2021(admins)

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI