1. 程式人生 > >Linux基礎系列:常用命令(2)

Linux基礎系列:常用命令(2)

用戶和組 查看 -- tdi 作業二 其他 配置文件 解鎖 gid

 1 作業一:
 2 1)    新建用戶natasha,uid為1000,gid為555,備註信息為“master”
 3 groupadd -g 555 natasha
 4 useradd -u 1000 -g 555 -c master natasha
 5 id natasha
 6 
 7 2)    修改natasha用戶的家目錄為/Natasha
 8 usermod -md /Natasha natasha
 9 
10 3)    查看用戶信息配置文件的最後一行
11 tail -1 /etc/passwdtai
12 
13 4)    為natasha用戶設置密碼“12314 echo 
123 | passwd --stdin natasha 15 16 5) 查看用戶密碼配置文件的最後一行 17 tail -1 /etc/shadow 18 19 6) 將natasha用戶賬戶鎖定 20 usermod -L natasha 21 22 7) 將natasha用戶賬戶解鎖 23 usermod -U natasha 24 25 8) 新建組police,gid為1999 26 groupadd -g 1999 police 27 28 9) 查看組配置文件的最後一行 29 tail -1 /etc/group 30 31 10) 將natasha用戶加入police組
32 usermod natasha -a -G police 33 34 11) 修改police組的組名為jingcha 35 groupmod -n jingcha police 36 37 12) 刪除natasha用戶,連家目錄和郵箱一起刪除 38 userdel -r natasha 39 40 13) 刪除jingcha組 41 groudel jingcha 42 43 作業二: 44 1) 在用戶的主目錄下創建目錄test,進入test創建空文件file1 45 mkdir /test/ 46 cd /test 47 touch file1 48
49 2) 以長格式形式顯示文件信息,註意文件的權限和所屬用戶和組 50 ls -l file1 51 52 3) 為文件file1設置權限,使其他用戶可以對此文件進行寫操作。 53 chmod o=r file1 54 55 4) 查看設置結果 56 ls -l file1 57 58 5) 取消同組用戶對文件file1的讀取權限,並查看設置結果。 59 chmod g-r file1 60 ls -l file1 61 62 6) 用數字表示法為文件file設置權限,所有者可讀、可寫、可執行,所屬組用戶和其他用戶只具有讀和執行的權限。設置完成後查看設置結果。 63 chmod 755 file1 64 ls -l filel 65 66 7) 用數字形式更改文件file1的權限,使所有者只能讀取此文件。其他任何用戶都沒有權限。查看設置結果。 67 chmod 400 file1 68 ls -l filel 69 70 8) 回到上層目錄,查看test的權限 71 cd .. 72 ll -d /test 73 74 9) 為其他用戶添加對此目錄的寫權限 75 chmod -R 0+w /test

Linux基礎系列:常用命令(2)