第五 六單元練習

2021-07-25 18:31:15 字數 3909 閱讀 7623

內容:新建使用者組,shengchan, caiwu, jishu

1)tom是生產組的附加使用者

2)harry是財務組的附加使用者

3)leo是jishu組的附加使用者

4)新建admin使用者,不屬於以上提到的三個部門

[root@westos desktop]# groupadd shengchan

[root@westos desktop]# gruopadd caiwu

bash: gruopadd: command not found

[root@westos desktop]# groupadd caiwu

[root@westos desktop]# groupadd jishu

[root@westos desktop]# useradd -g shengchan tom

[root@westos desktop]# uesradd -g caisu harry; useradd -g jishu leo;

bash: uesradd: command not found

[root@westos desktop]# useradd -g caisu harry; useradd -g jishu leo;

useradd: group 'caisu' does not exist

useradd: user 'leo' already exists

[root@westos desktop]# useradd -g caiwu harry; useradd -g jishu leo;

creating mailbox file: file exists

useradd: user 'leo' already exists

[root@westos desktop]# useradd admin

[root@westos desktop]# id tom; id harry; id leo; id admin

uid=505(tom) gid=505(tom) groups=505(tom),508(shengchan)

uid=507(harry) gid=511(harry) groups=511(harry),509(caiwu)

uid=506(leo) gid=506(leo) groups=506(leo),510(jishu)

uid=508(admin) gid=512(admin) groups=512(admin)

1)/cw目錄為財務部門的儲存目錄,只能對財務部門寫入

2)現有工具/mnt/touch命令,要求任何人可以通過該命令向/cw目錄新建檔案,但是只能新建,不能遊覽和進入。

[root@westos pub]# mkdir /cw   ##新建cw目錄

[root@westos pub]# chgrp caiwu /cw ##改變cw的所屬組

[root@westos pub]# chmod 770 /cw ##改變cw的許可權

[root@westos pub]# ls -d /cw ##檢視cw的許可權

/cw[root@westos pub]# ls -ld /cw ##檢視cw的許可權

drwxrwx---. 2 root caiwu 4096 jan 2 16:42 /cw

2思路:設定/mnt/touch的suid許可權:

步驟:1.新建乙個二進位制檔案,讓任何人都可以執行這個檔案(這樣不安全)

2.改變/mnt/touch的所有者,讓其為root

3.設定/mnt/touch的suid許可權,此時任何人執行這個命令會獲得root許可權

4.設定/cw的root許可權為只能新建,即w

[root@westos pub]# ll /mnt/touch 

-rw-r--r--. 1 root root 0 jan 3 18:35 /mnt/touch

[root@westos pub]# chmod ogo+x /m

media/ misc/ mnt/

[root@westos pub]# chmod ogo+x /mnt/touch

[root@westos pub]# ll /mnt/touch

-rw-r-xr-x. 1 root root 0 jan 3 18:35 /mnt/touch

[root@westos pub]# chmod ugo+x /mnt/touch

[root@westos pub]# ll /mnt/touch

-rwxr-xr-x. 1 root root 0 jan 3 18:35 /mnt/touch

[root@westos pub]# chmod u+s /mnt/touch ##執行這個二進位制檔案,會獲得這個root許可權

[root@westos pub]# chmod u=w /cw

[root@westos pub]# ls /cw

[root@westos pub]# ll -d /cw

d-w-rwx---. 2 root caiwu 4096 jan 2 16:42 /cw

1./pub目錄是公共儲存目錄對所有使用者可以讀寫執行,但是使用者只能刪除自己的檔案

思路:對目錄設定sbit許可權,在這個目錄中新建的檔案只有使用者與root有權刪除

[root@westos /]# chmod 1777 /pub

[root@westos /]# ls -d

.[root@westos /]# ls -d /pub

/pub

[root@westos /]# ll -d /pub

drwxrwxrwt. 2 root root 4096 jan 2 13:39 /pub

測試:

[harry@westos pub]$ touch fileharry

[harry@westos pub]$ ls

fileharry filetom test

[harry@westos pub]$ rm -f filetom

rm: cannot remove `filetom': operation not permitted

[harry@westos pub]$

[tom@westos pub]$ ls

fileharry filetom test

[tom@westos pub]$ rm -f fileharry

rm: cannot remove `fileharry': operation not permitted

2.設定普通使用者新建檔案許可權為"r--r-----"

思路:普通使用者新建檔案的許可權是644(777-022-111),變成440則需要將umask變成226

[tom@westos pub]$ umask 226

[tom@westos pub]$ touch file1

[tom@westos pub]$ ls -l file

ls: cannot access file: no such file or directory

[tom@westos pub]$ ls -l file1

-r--r-----. 1 tom tom 0 jan 3 19:13 file1

5.設定admin使用者可以通過sudo自由新建新使用者

思路:通過visudo修該sudo檔案

##允許admin使用者新建使用者

admin   all=(root)      nopasswd: /usr/sbin/useradd

最後一行新增以上一行,表示admin使用者立可以在任何主機上以root身份不要密碼執行 /usr/sbin/useradd

五六單元練習

五 六單元練習 1.新建使用者組,shengchan,caiwu,jishu 2.新建使用者要求如下 tom 是shengchan組的附加使用者 harry 是caiwu組的附加使用者 leo 是jishu組的附加使用者 新建admin使用者,此使用者不屬於以上提到的三個部門 3.新建目錄要求如下 ...

第五六周閱讀筆記

幾種主要的低壓接地系統的概念 tn,tt,it 1.tt 方式供電系統 tt 方式是指將電氣裝置的金屬外殼直接接地的保護系統,稱為保護接地系統,也稱 tt 系統。第乙個符號 t 表示電力系統中性點直接接地 第二個符號 t 表示負載裝置金屬外殼和正常不帶電的金屬部分與大地直接聯接,而與系統如何接地無關...

第五六周讀書筆記

一.幾種低壓接地系統 1.tn系統 tn系統即電源中性點直接接地 裝置外露可導電部分與電源中性點直接電氣連線的系統。tn系統主要是靠單相碰殼故障變成單相短路故障 短路電流是 tt 系統的 5.3 倍 並通過短路保護切斷電源來實施電擊防護的。從電擊防護的角度來說,單相短路電流大或過電流保護器動作電流值...