国产成人精品18p,天天干成人网,无码专区狠狠躁天天躁,美女脱精光隐私扒开免费观看

linux權限管理的相關(guān)命令

發(fā)布時(shí)間:2021-09-14 18:13 來(lái)源:億速云 閱讀:0 作者:chen 欄目: 服務(wù)器 歡迎投稿:712375056

這篇文章主要介紹“l(fā)inux權限管理的相關(guān)命令”,在日常操作中,相信很多人在linux權限管理的相關(guān)命令問(wèn)題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對大家解答”linux權限管理的相關(guān)命令”的疑惑有所幫助!接下來(lái),請跟著(zhù)小編一起來(lái)學(xué)習吧!

前言

practice makes perfect

題目

1.新建用戶(hù)組,shengchan,caiwu,jishu

2.新建用戶(hù)要求如下:

tom是shengchan組的附加用戶(hù)

harry是caiwu組的附加用戶(hù)

leo是jishu組的附加用戶(hù)

新建admin用戶(hù),此用戶(hù)不屬于以上提到的三個(gè)部門(mén)

3.新建目錄要求如下:

*/pub目錄為公共存儲目錄對所有用戶(hù)可以讀,寫(xiě),執行,但用戶(hù)只能刪除屬于自己的文件

*/sc目錄為生產(chǎn)部存儲目錄只能對生產(chǎn)部人員可以寫(xiě)入

并且生產(chǎn)部人員所建立的文件都自動(dòng)歸屬到shengchan組

*/cw目錄為i財務(wù)部存儲目錄只能對財務(wù)部人員可以寫(xiě)入

并且財務(wù)部人員所建立的文件都自動(dòng)歸屬到caiwu組

*admin用戶(hù)能用touch工具在/sc目錄和/cw目錄中任意建立文件,但不能刪除文件

4.設定普通用戶(hù)新建文件權限為“r–r-----”

5.設定admin用戶(hù)可以通過(guò)sudo自由建立新用戶(hù)

命令

1.新建用戶(hù)組:

[root@workstation ~]# groupadd shengchan

[root@workstation ~]# groupadd caiwu

[root@workstation ~]# groupadd jishu

結果:

==> /etc/passwd <==

gdm:x:42:42::/var/lib/gdm:/sbin/nologin

gnome-initial-setup:x:976:976::/run/gnome-initial-setup/:/sbin/nologin

avahi:x:70:70:Avahi m/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin

tom:x:1001:1004::/home/tom:/bin/bash

harry:x:1002:1005::/home/harry:/bin/bash

leo:x:1003:1006::/home/leo:/bin/bash

admin:x:1004:1007::/home/admin:/bin/bash

==> /etc/group <==

shengchan:x:1001:tom

caiwu:x:1002:harry

jishu:x:1003:leo

tom:x:1004:

harry:x:1005:

leo:x:1006:

admin:x:1007:

===>/home message<==

total 0

drwx------. 4 admin   admin   93 Jan 10 21:22 admin

drwx------. 4 harry   harry   93 Jan 10 21:21 harry

drwx------. 4 leo     leo     93 Jan 10 21:21 leo

drwx------. 4 student student 89 May 21  2019 student

drwx------. 4 tom     tom     93 Jan 10 21:21 tom

2.分別給用戶(hù)附加組

[root@workstation ~]# useradd -G shengchan tom

[root@workstation ~]# useradd -G caiwu harry

[root@workstation ~]# useradd -G jishu leo

[root@workstation ~]# useradd admin

3.分別新建目錄,并且賦予適當權限!

[root@workstation mnt]# mkdir pub sc cw

pub目錄1.不能讓非擁有人刪除,可以chmod 1/o+t。2.任何人都是滿(mǎn)權所以是chmod 777。

[root@workstation mnt]# chmod 1777 pub

sc目錄1.只能讓生產(chǎn)部的人寫(xiě)入,所以他只有他的所屬組的成員和文件所有人可以寫(xiě)入,所以權限是775    2.讓這個(gè)文件的所屬組為sc。

[root@workstation mnt]# chmod -R 2775 sc

[root@workstation mnt]# chgrp -R shengchan sc

同上:

[root@workstation mnt]# chmod -R 2775 cw

[root@workstation mnt]# chgrp -R caiwu cw

結果:

/mnt:

total 0

drwxr-xr-x. 2 root caiwu     6 Jan 10 21:29 cw

drwxrwxrwt. 2 root root      6 Jan 10 21:29 pub

drwxr-xr-x. 2 root shengchan 6 Jan 10 21:29 sc

下放root權力給admin:

打開(kāi)sudres文件:

[root@workstation mnt]# vim /etc/sudoers

在101行加入下列代碼:

admin   workstation.lab.example.com=(root)  NOPASSWD:/bin/touch

1

2

3

4

5

結果:

[root@workstation mnt]# su - admin

Last login: Fri Jan 10 22:25:48 EST 2020 on pts/0

[admin@workstation ~]$ sudo touch /mnt/sc/a

[admin@workstation ~]$ sudo rm -f /mnt/sc/a

[sudo] password for admin: 

Sorry, user admin is not allowed to execute '/bin/rm -f /mnt/sc/a' as root on workstation.lab.example.com.

4.為了改變普通用戶(hù)建立的文件的權限,所以我們要去永久的更改文件閥值

查看目前閥值:

[root@workstation mnt]# umask

0022   即755

更改下列兩個(gè)文件中的umask值

[root@workstation mnt]# vim /etc/bashrc

[root@workstation mnt]# vim /etc/profile

查看更改后的閥值

[tom@workstation ~]$ umask

0337   即440

5.繼續給admin下放權限:

打開(kāi)文件:

[root@workstation mnt]# vim /etc/sudoers

101行:

結果:

[root@workstation mnt]# su - admin

Last login: Fri Jan 10 23:46:41 EST 2020 on pts/0

[admin@workstation ~]$ sudo useradd admin11

結果:

admin11:x:1005:1008::/home/admin11:/bin/bash

建立新用戶(hù)成功!

命令總結

先后涉及到的命令都有:

新加用戶(hù)和用戶(hù)組

useradd

groupadd

給用戶(hù)附加組:

useradd -G

usermod -aG

建立文件與目錄:

mkdir

touch

更改目錄權限且設置特殊權限:

chmod -R 1777

chmod -R 2775

下放root權力:

vim /etc/sudoers

admin hostname=(root) NOPASSWD: bin/touch, /usr/sbin/useradd

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自本網(wǎng)站內容采集于網(wǎng)絡(luò )互聯(lián)網(wǎng)轉載等其它媒體和分享為主,內容觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如侵犯了原作者的版權,請告知一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容,聯(lián)系我們QQ:712375056,同時(shí)歡迎投稿傳遞力量。

最近中文字幕在线中文视频| 国产精品久久久久久久9999| 欧美另类熟妇XXXX久久A片| 东京热无码国产精品| 无码区A∨视频体验区30秒| 精品自拍亚洲一区在线|