第三週做業

一、顯示/etc目錄下,以非字母開頭,後面跟了一個字母以及其它任意長度任意字符的文件或目錄

ls /etc/ |grep "^[^[:alpha:]][[:alpha:]]\{1\}.*"

二、複製/etc目錄下全部以p開頭,以非數字結尾的文件或目錄到/tmp/mytest1目錄中。

mkdir -p /tmp/mytest1 linux

cp -r /etc/p*[^[:digit:]] /tmp/mytest1git

三、將/etc/issue文件中的內容轉換爲大寫後保存至/tmp/issue.out文件中

cat /etc/issue |tr 'a-z' 'A-Z' >>/tmp/issue.out

四、請總結描述用戶和組管理類命令的使用方法並完成如下練習:

(1)、建立組distro,其GID爲2019;shell

[root@localhost home]# groupadd -g 2019 distro
[root@localhost home]#getent group distro
distro:x:2019:
[root@localhost home]#bash

(2)、建立用戶mandriva, 其ID號爲1005;基本組爲distro;

[root@localhost home]#useradd -u 1005 -g distro mandriva
[root@localhost home]#id mandriva
uid=1005(mandriva) gid=2019(distro) groups=2019(distro)
[root@localhost home]#ide

(3)、建立用戶mageia,其ID號爲1100,家目錄爲/home/linux;
ui

[root@localhost home]#useradd -u 1100 -d /home/linux mageia
[root@localhost home]#id 1100
uid=1100(mageia) gid=1100(mageia) groups=1100(mageia)
[root@localhost home]#su - mageia
[mageia@localhost ~]$pwd
/home/linux
[mageia@localhost ~]$加密

(4)、給用戶mageia添加密碼,密碼爲mageedu,並設置用戶密碼7天后過時
code

[root@localhost home]#echo mageedu |passwd --stdin mageia
Changing password for user mageia.
passwd: all authentication tokens updated successfully.
[root@localhost home]#
[root@localhost home]#chage -M 7 mageia
[root@localhost home]#getent shadow mageia
mageia:$6$bA2Hf5EJ$xP/QRTQN3Sivh/iAfCLCgZFEHvu6zqL4qVPzf3vPRcxBTqN2fmy9pixKUCSnWnI./Fd4bVvDrp7dA1rDJeS8p1:18435:0:7:7:::token

(5)、刪除mandriva,但保留其家目錄;

[root@localhost home]#userdel mandriva
[root@localhost home]#ll /home/mandriva
total 0
[root@localhost home]#ll -d /home/mandriva
drwx------. 3 1005 distro 4096 Jun 22 22:13 /home/mandriva
[root@localhost home]#get

(6)、建立用戶slackware,其ID號爲2002,基本組爲distro,附加組peguin;

[root@localhost home]#groupadd peguin
[root@localhost home]#useradd -u 2002 -g distro -G peguin slackware
[root@localhost home]#id 2002
uid=2002(slackware) gid=2019(distro) groups=2019(distro),2020(peguin)
[root@localhost home]#

(7)、修改slackware的默認shell爲/bin/tcsh;

[root@localhost home]#getent passwd slackware
slackware:x:2002:2019::/home/slackware:/bin/bash
[root@localhost home]#usermod -s /bin/tcsh slackware
[root@localhost home]#getent passwd slackware
slackware:x:2002:2019::/home/slackware:/bin/tcsh

(8)、爲用戶slackware新增附加組admins;

[root@localhost home]#id slackware
uid=2002(slackware) gid=2019(distro) groups=2019(distro),2020(peguin)
[root@localhost home]#groupadd admins
[root@localhost home]#usermod -a -G admins slackware[root@localhost home]#id slackware uid=2002(slackware) gid=2019(distro) groups=2019(distro),2020(peguin),2021(admins)

相關文章
相關標籤/搜索