linux file management and user management practice

1, the display / etc directory, start with a non-letter followed by a letter of the file or directory, and other characters of any arbitrary length.

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

2, the next copy / etc directory of all start with p, ending in a non-digital files or directories to / tmp / mytest1 directory.

[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, the contents of / etc / issue file conversion to save a file after capital /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, please use summary description of user and group management class command and complete the following exercises:

(1), create groups distro, its GID of 2019;

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

(2) creating a user Mandriva, its ID number is 1005; substantially Distro group;

[@ centos7 the root etc] -u # 1005 mandriva the useradd -g Distro
[@ centos7 the root etc] # ID # mandriva mandriva UID number verification and basic groups
uid = 1005 (mandriva) gid = 2019 (distro) groups = 2019 (distro )

(3) create a user mageia, its ID number is 1100, the home directory is / home / linux;

[Root Atto Centos7 Etc] # Useradd Mageia -U 1100 -D / Home / Linux
[Root Atto Centos7 Etc] # Getent Passwd Mageia #验证Results
mageia: x: 1100: 1100 :: / home / linux: / bin / bash

(4), to add the user mageia password, the password is mageedu, and user passwords expire after 7 days

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

(5), delete mandriva, but retain their home directory;

[root @ centos7 etc] # userdel mandriva
[root @ centos7 etc] # LS / Home / validation results # mandriva directory still exists
diyoujia linux mandriva slackware test

(6), to create a user Slackware, its ID number is 2002, the basic group Distro, additional sets peguin;

[root @ centos7 etc] # useradd -u 2002 -g Distro Slackware -G peguin
[root @ centos7 etc] # # validate the results of the above mentioned id Slackware
uid = 2002 (slackware) gid = 2019 (distro) groups = 2019 (distro), 2020 (peguin)

(7), to modify the default shell slackware / bin / tcsh;

[root @ centos7 etc] # Slackware the chsh -s / bin / tcsh
[root @ centos7 etc] # # validate the getent passwd Slackware results
slackware: x: 2002: 2019 :: / home / slackware: / bin / tcsh

(8), to add additional user slackware Admins group;

[root @ centos7 etc] # Slackware -Ag the usermod Admins
[root @ centos7 etc] # # validate the results of the above mentioned id Slackware
uid = 2002 (slackware) gid = 2019 (distro) groups = 2019 (distro), 2020 (peguin), 2021 ( admins)

Guess you like

Origin blog.51cto.com/767958/2471540