1、显示/etc目录下,以非字母开头,后面跟了一个字母以及其它任意长度任意字符的文件或目录
[root@centos_1 ~]# ll /etc/[^a-z]* -rw-r--r-- 1 root root 0 Oct 13 22:18 /etc/1test [root@centos_1 ~]# ll /etc/[^a-z][a-z]* -rw-r--r-- 1 root root 0 Oct 13 22:18 /etc/1test [root@centos_1 ~]#
[root@centos_1 mytest1]# cp -r /etc/p[^0-9] /tmp/mytest1/ [root@centos_1 mytest1]# ll total 0 drwxr-xr-x 5 root root 52 Oct 13 22:24 pm [root@centos_1 mytest1]# pwd /tmp/mytest1 [root@centos_1 mytest1]#
[root@centos_1 mytest1]# cat /etc/issue \S Kernel \r on an \m [root@centos_1 mytest1]# cat /etc/issue | tr '[a-z]' '[A-Z]' >>/tmp/issue.out [root@centos_1 mytest1]# cat /tmp/issue.out \S KERNEL \R ON AN \M [root@centos_1 mytest1]#
(1)、创建组distro,其GID为2019;
[root@centos_1 mytest1]# cat /etc/group | grep distro distro:x:2019: [root@centos_1 mytest1]# groupadd distro -g 2019
[root@centos_1 mytest1]# useradd mandriva -u 1005 -g distro [root@centos_1 mytest1]# tail /etc/passwd tcpdump:x:72:72::/:/sbin/nologin ntp:x:38:38::/etc/ntp:/sbin/nologin saslauth:x:997:76:Saslauthd user:/run/saslauthd:/sbin/nologin mailnull:x:47:47::/var/spool/mqueue:/sbin/nologin smmsp:x:51:51::/var/spool/mqueue:/sbin/nologin zabbix:x:996:995:Zabbix Monitoring System:/var/lib/zabbix:/sbin/nologin apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin tom:x:5001:5001::/tmp/tom:/bin/zsh help:x:5002:5002::/home/help:/bin/bash mandriva:x:1005:2019::/home/mandriva:/bin/bash
[root@centos_1 mytest1]# useradd mageia -u 1100 -d /homenux [root@centos_1 mytest1]# tail /etc/passwd ntp:x:38:38::/etc/ntp:/sbin/nologin saslauth:x:997:76:Saslauthd user:/run/saslauthd:/sbin/nologin mailnull:x:47:47::/var/spool/mqueue:/sbin/nologin smmsp:x:51:51::/var/spool/mqueue:/sbin/nologin zabbix:x:996:995:Zabbix Monitoring System:/var/lib/zabbix:/sbin/nologin apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin tom:x:5001:5001::/tmp/tom:/bin/zsh help:x:5002:5002::/home/help:/bin/bash mandriva:x:1005:2019::/home/mandriva:/bin/bash mageia:x:1100:1100::/homenux:/bin/bash
(4)、给用户mageia添加密码,密码为mageedu,并设置用户密码7天后过期
[root@centos_1 mytest1]# passwd -x 7 mageia Adjusting aging data for user mageia. passwd: Success [root@centos_1 mytest1]# passwd -S mageia mageia LK 2019-10-13 0 7 7 -1 (Password locked.) [root@centos_1 mytest1]# passwd mageia Changing password for user mageia. New password: BAD PASSWORD: The password is shorter than 8 characters Retype new password: passwd: all authentication tokens updated successfully. [root@centos_1 mytest1]# passwd -S mageia mageia PS 2019-10-13 0 7 7 -1 (Password set, SHA512 crypt.) [root@centos_1 mytest1]#
[root@centos_1 mytest1]# userdel mandriva [root@centos_1 mytest1]# ll /home/mandriva/ total 0 [root@centos_1 mytest1]# ll /home total 0 drwx------ 2 help help 62 Oct 13 22:42 help drwx------ 2 1005 distro 62 Oct 13 23:14 mandriva [root@centos_1 mytest1]#
[root@centos_1 mytest1]# groupadd peguin [root@centos_1 mytest1]# useradd slackware -u 2002 -g distro -G peguin [root@centos_1 mytest1]# tail /etc/passwd ntp:x:38:38::/etc/ntp:/sbin/nologin saslauth:x:997:76:Saslauthd user:/run/saslauthd:/sbin/nologin mailnull:x:47:47::/var/spool/mqueue:/sbin/nologin smmsp:x:51:51::/var/spool/mqueue:/sbin/nologin zabbix:x:996:995:Zabbix Monitoring System:/var/lib/zabbix:/sbin/nologin apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin tom:x:5001:5001::/tmp/tom:/bin/zsh help:x:5002:5002::/home/help:/bin/bash mageia:x:1100:1100::/homenux:/bin/bash slackware:x:2002:2019::/home/slackware:/bin/bash [root@centos_1 mytest1]#
[root@centos_1 mytest1]# usermod slackware -s /bin/tcsh [root@centos_1 mytest1]# tail /etc/passwd ntp:x:38:38::/etc/ntp:/sbin/nologin saslauth:x:997:76:Saslauthd user:/run/saslauthd:/sbin/nologin mailnull:x:47:47::/var/spool/mqueue:/sbin/nologin smmsp:x:51:51::/var/spool/mqueue:/sbin/nologin zabbix:x:996:995:Zabbix Monitoring System:/var/lib/zabbix:/sbin/nologin apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin tom:x:5001:5001::/tmp/tom:/bin/zsh help:x:5002:5002::/home/help:/bin/bash mageia:x:1100:1100::/homenux:/bin/bash slackware:x:2002:2019::/home/slackware:/bin/tcsh [root@centos_1 mytest1]#
[root@centos_1 mytest1]# groupadd admins [root@centos_1 mytest1]# usermod slackware -G admins [root@centos_1 mytest1]# tail /etc/passwd ntp:x:38:38::/etc/ntp:/sbin/nologin saslauth:x:997:76:Saslauthd user:/run/saslauthd:/sbin/nologin mailnull:x:47:47::/var/spool/mqueue:/sbin/nologin smmsp:x:51:51::/var/spool/mqueue:/sbin/nologin zabbix:x:996:995:Zabbix Monitoring System:/var/lib/zabbix:/sbin/nologin apache:x:48:48:Apache:/usr/share/httpd:/sbin/nologin tom:x:5001:5001::/tmp/tom:/bin/zsh help:x:5002:5002::/home/help:/bin/bash mageia:x:1100:1100::/homenux:/bin/bash slackware:x:2002:2019::/home/slackware:/bin/tcsh [root@centos_1 mytest1]# cat /etc/group | grep admins admins:x:5004:slackware [root@centos_1 mytest1]#