1、 显示/etc目录下,以非字母开头,后面跟了一个字母以及其它任意长度任意字符的文件或目录
[[email protected] ~]# ls -a /etc/[^[:alpha:]][[:alpha:]]
ls: cannot access /etc/[^[:alpha:]][[:alpha:]]: No such file or directory
目前etc下没有这种文件和目录,建立几个符合要求的文件后如下:
[[email protected] ~]# touch /etc/1abc.txt
[[email protected] ~]# touch /etc/2abc.txt
[[email protected] ~]# touch /etc/1a.txt
[[email protected] ~]# ls -a /etc/[^[:alpha:]][[:alpha:]]
/etc/1abc.txt /etc/1a.txt /etc/2abc.txt
[[email protected] ~]#
2、 复制/etc目录下所有以p开头,以非数字结尾的文件或目录到/tmp/mytest1目录中。
首先在/tmp目录下通过mkdir命令新建一个mytest1目录,然后通过cp命令将符合条件的文件或者目录拷贝到目标文件
[[email protected] ~]# mkdir /tmp/mytest1
[[email protected] ~]# cp -a /etc/[p][^[:digit:]] /tmp/mytest1
[[email protected] ~]# ls !
ls -a /etc/[p][^[:digit:]] /tmp/mytest1
/etc/papersize /etc/passwd /etc/passwd- /etc/pbm2ppa.conf /etc/pinforc /etc/pnm2ppa.conf /etc/printcap /etc/profile /etc/protocols
/etc/pam.d:
. chsh fingerprint-auth gdm-launch-environment liveinst password-auth postlogin runuser smartcard-auth sshd su-l vlock
.. config-util fingerprint-auth-ac gdm-password login password-auth-ac postlogin-ac runuser-l smartcard-auth-ac su system-auth vmtoolsd
atd crond gdm-autologin gdm-pin other pluto ppp screen smtp sudo system-auth-ac xserver
chfn cups gdm-fingerprint gdm-smartcard passwd polkit-1 remote setup smtp.postfix sudo-i systemd-user
/etc/pki:
. .. CA ca-trust fwupd fwupd-metadata java nssdb nss-legacy rpm-gpg rsyslog tls
/etc/plymouth:
. .. plymouthd.conf
/etc/pm:
. .. config.d power.d sleep.d
/etc/popt.d:
. ..
/etc/postfix:
. .. access canonical generic header_checks main.cf master.cf relocated transport virtual
/etc/ppp:
. .. chap-secrets eaptls-client eaptls-server ip-down ip-down.ipv6to4 ip-up ip-up.ipv6to4 ipv6-down ipv6-up options pap-secrets peers
/etc/prelink.conf.d:
. .. fipscheck.conf grub2.conf libreswan-fips.conf nss-softokn-prelink.conf
/etc/profile.d:
. 256term.csh abrt-console-notification.sh colorgrep.csh colorls.csh csh.local lang.csh less.csh PackageKit.sh vim.csh vte.sh which2.sh
.. 256term.sh bash_completion.sh colorgrep.sh colorls.sh flatpak.sh lang.sh less.sh sh.local vim.sh which2.csh
/etc/pulse:
. .. client.conf daemon.conf default.pa system.pa
/etc/purple:
. .. prefs.xml
/etc/python:
. .. cert-verification.cfg
/tmp/mytest1:
. pam.d passwd pbm2ppa.conf pki pm popt.d ppp printcap profile.d pulse python
.. papersize passwd- pinforc plymouth pnm2ppa.conf postfix prelink.conf.d profile protocols purple
[[email protected] ~]#
3、将/etc/issue文件中的内容转换为大写后保存至/tmp/issue.out文件中
通过tr命令对文件内容进行转换
4、请总结描述用户和组管理类命令的使用方法并完成以下练习:
(1)、创建组distro,其GID为2019;
groupadd -g 2019 distro
(2)、创建用户mandriva, 其ID号为1005;基本组为distro;
(3)、创建用户mageia,其ID号为1100,家目录为/homenux;
(4)、给用户mageia添加密码,密码为mageedu,并设置用户密码7天后过期
(5)、删除mandriva,但保留其家目录;
(6)、创建用户slackware,其ID号为2002,基本组为distro,附加组peguin;
(7)、修改slackware的默认shell为/bin/tcsh;
(8)、为用户slackware新增附加组admins;
原文地址:https://blog.51cto.com/14697765/2476439