Lunix下用戶權(quán)限管理-命令大全_第1頁
Lunix下用戶權(quán)限管理-命令大全_第2頁
Lunix下用戶權(quán)限管理-命令大全_第3頁
Lunix下用戶權(quán)限管理-命令大全_第4頁
Lunix下用戶權(quán)限管理-命令大全_第5頁
已閱讀5頁,還剩4頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

用戶管理與權(quán)限實(shí)驗(yàn)?zāi)康模赫莆沼脩襞c組管理掌握高級權(quán)限的使用掌握訪問控制列表實(shí)驗(yàn)步驟:步驟一、用戶管理創(chuàng)建用戶useradd的幾個參數(shù):-c描述-d家目錄-u

uid號-g

私有組-G

把這個用戶附加到其它組中去-s

shell環(huán)境變量

/bin/bash

/sbin/nologin它無法登陸到本地,遠(yuǎn)程用戶可以創(chuàng)建一個用戶user2,我們怎么樣知道我們創(chuàng)建了user2了呢?Id一下用戶[root@freeit~]#useradd

user2[root@freeit~]#id

user2uid=1001(user2)

gid=1001(user2)

組=1001(user2)我們也可以查看用戶的配置文件/etc/passwd,里面記載這所有用戶的信息[root@freeit~]#vim/etc/passwd在/etc/passwd下,有三種用戶:第一種:超級管理員root,uid為0第二種:系統(tǒng)服務(wù)用戶,uid為1~999第三種:(紅帽7)普通(本地)用戶,uid為1000往后我們的紅帽6系統(tǒng)服務(wù)用戶uid是1-499.Usermod修改服務(wù)用戶Userdel–r

刪除服務(wù)用戶-r參數(shù):創(chuàng)建一個用戶或組大概會在這六個地方創(chuàng)建信息/etc/passwd

/etc/shadow

/etc/group

/etc/gshadow/home

/var/spool/mail不添加-r參數(shù)刪除,會刪除這些/etc/passwd

/etc/shadow

/etc/group

/etc/gshadow配置信息,但不刪除/home

/var/spool/mail這兩個配置信息添加-r參數(shù)刪除會刪除所有的配置信息步驟二、組管理創(chuàng)建一個dongshihui組,對這個組設(shè)置一個密碼[root@freeit~]#groupadd

dongshihui[root@freeit~]#gpasswd

dongshihui正在修改dongshihui組的密碼密碼:切換到普通用戶user1上,把user1加入到dongshihui組中[root@freeit~]#

su

-

user1ABRThasdetected1problem(s).Formoreinforun:abrt-clilist[user1@freeit~]$newgrp

dongshihui密碼:[user1@freeit~]$iduid=1000(user1)gid=1002(dongshihui)組=1000(user1),1002(dongshihui)環(huán)境=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023[user1@freeit~]$Groupdel

-r刪除組步驟三、高級權(quán)限SUID權(quán)限:SUID權(quán)限僅僅只對可執(zhí)行文件(命令文件)有效,對普通文件無意義,只出現(xiàn)在第三位,如果一個可執(zhí)行文件有SUID權(quán)限,那么其它用戶在執(zhí)行這個可執(zhí)行文件過程時會臨時擁有這個可執(zhí)行文件的所有者權(quán)限[root@freeitmnt]#ll/bin/ls-rwxr-xr-x.1rootroot1176161月

252014/bin/ls[root@freeitmnt]#ls

-ld

/rootdr-xr-x---.14rootroot40965月

416:56/root[root@freeitmnt]#su

-user1上一次登錄:一5月

417:15:44CST2015pts/0上[user1@freeit~]$ls

/rootls:無法打開目錄/root:權(quán)限不夠[user1@freeit~]$touch

/root/user1touch:無法創(chuàng)建"/root/user1":權(quán)限不夠[user1@freeit~]$exit登出[root@freeitmnt]#chmod

u+s/bin/ls[root@freeitmnt]#chmod

u+s

/bin/touch[root@freeitmnt]#ll/bin/ls-rwsr-xr-x.1rootroot1176161月

252014/bin/ls[root@freeitmnt]#ll/bin/touch-rwsr-xr-x.1rootroot624321月

252014/bin/touch[root@freeitmnt]#su

-user1上一次登錄:一5月

417:19:35CST2015pts/1上[user1@freeit~]$ls

/rootanaconda-ks.cfg

test1

公共

模板

視頻

圖片

文檔

下載

音樂

桌面[user1@freeit~]$touch

/root/test1[user1@freeit~]$ll/root總用量4-rw-------.1rootroot

15034月

2717:37anaconda-ks.cfg-rw-rw-r--.1rootuser1

05月

417:21test1drwxr-xr-x.2rootroot

64月

2709:47公共drwxr-xr-x.2rootroot

64月

2709:47模板drwxr-xr-x.2rootroot

64月

2709:47視頻drwxr-xr-x.2rootroot

64月

2709:47圖片drwxr-xr-x.2rootroot

64月

2709:47文檔drwxr-xr-x.2rootroot

64月

2709:47下載drwxr-xr-x.2rootroot

64月

2709:47音樂drwxr-xr-x.2rootroot

64月

2709:47桌面SGID權(quán)限:SGID權(quán)限僅僅只對可執(zhí)行文件(命令文件)有效,對普通文件無意義,只出現(xiàn)在第6位,如果一個可執(zhí)行文件有SGID權(quán)限,那么其它用戶在執(zhí)行這個可執(zhí)行文件過程中會臨時擁有這個可執(zhí)行文件的所屬組權(quán)限。[root@freeitmnt]#ll

/bin/ls-rwxr-xr-x.1rootroot1176161月

252014/bin/ls[root@freeitmnt]#chmod

g+s

/bin/ls[root@freeitmnt]#ll/bin/ls-rwxr-sr-x.1rootroot1176161月

252014/bin/ls[root@freeitmnt]#su

-

user1上一次登錄:一5月

417:20:57CST2015pts/1上[user1@freeit~]$ls

/rootanaconda-ks.cfg

test1

公共

模板

視頻

圖片

文檔

下載

音樂

桌面sticky權(quán)限:t權(quán)限僅僅只對目錄有效,對任何文件無意義!只出現(xiàn)在第9位!如果一個目錄有t權(quán)限,那么只有文件所有者和root用戶才能刪除文件,其它用戶無法執(zhí)行刪除文件的操作!假如/tmp目錄權(quán)限是rwxrwxrwt

root用戶可以在這個目錄下創(chuàng)建和刪除任何文件!

但是普通用戶user1只能刪除自己創(chuàng)建的文件,而不能刪除user2用戶的文件(即使user1對user2用戶的文件的w權(quán)限)!

實(shí)際應(yīng)用:一般用于重要目錄設(shè)置一個t權(quán)限.這樣可以防止誤刪除文件.

[root@freeitmnt]#ls

-ld/tmpdrwxrwxrwx.18rootroot40965月

417:46/tmp[root@freeitmnt]#chmod

o+t

/tmp[root@freeitmnt]#ls

-ld

/tmpdrwxrwxrwt.18rootroot40965月

417:46/tmp[root@freeitmnt]#cd/tmp[root@freeittmp]#su

user1[user1@freeittmp]$touch

user1[user1@freeittmp]$su

user2密碼:[user2@freeittmp]$touch

user2[user2@freeittmp]$ll-rw-rw-r--.1user1user1

05月

417:59user1-rw-rw-r--.1user2user2

05月

418:00user2

[user2@freeittmp]$rm-rf

user1rm:無法刪除"user1":不允許的操作步驟四、文件訪問控制列表傳統(tǒng)權(quán)限設(shè)置無法針對單個用戶來設(shè)置權(quán)限!FACL(FileAccessControl

List)就是對傳統(tǒng)權(quán)限的補(bǔ)充,可以實(shí)現(xiàn)針對單個用戶做單獨(dú)權(quán)限設(shè)置getfacl

file|dir

查看這個文件或目錄的權(quán)限(針對單個用戶的)setfacl

-m

u|g|o|a:username|groupname:r|w|x

file|dir

設(shè)置權(quán)限在/tmp目錄下有個test文件,設(shè)置user1組用戶有rwx權(quán)限,user1用戶有rw權(quán)限,user2用戶有r權(quán)限,如果做了?[root@freeit/]#cd/tmp[root@freeittmp]#touch

test[root@freeittmp]#ll總用量0-rw-r--r--.1rootroot05月

811:22test[root@freeittmp]#getfacl

test#file:test#owner:root#group:rootuser::rw-group::r--other::r—可以看到getfacl查看的權(quán)限就是傳統(tǒng)權(quán)限,只不過換了個形式,現(xiàn)在我們對test文件設(shè)置下訪問控制列表,再來查看。[root@freeittmp]#setfacl

-m

g:user1:rwx

test[root@freeittmp]#setfacl

-m

u:user1:rw

test[root@freeittmp]#setfacl

-m

u:user2:r

test[root@freeittmp]#getfacl

test#file:test#owner:root#group:rootuser::rw-user:user1:rw-user:user2:r--group::r--group:user1:rwxmask::rwxother::r--用getfacl查看的權(quán)限其中既有傳統(tǒng)權(quán)限又有Facl權(quán)限注意事項(xiàng):在紅帽6系統(tǒng)中,后來創(chuàng)建的分區(qū)時ext4格式的,這個分區(qū)時不帶Facl功能的在紅帽7系統(tǒng)中,分區(qū)只要時xfs格式的,這些分區(qū)都會帶Facl功能的步驟五、權(quán)限委派權(quán)限委派就是將一部分功能委派給其它人查看/home,發(fā)現(xiàn)只有student一個用戶,切換student用戶下,useradd234用戶,權(quán)限拒絕[root@desktop30Desktop]#cd/home[root@desktop30home]#lsstudent[root@desktop30home]#su

student[student@desktop30home]$useradd

234bash:/usr/sbin/useradd:Permissiondenied修改/etc/sudoers文件,使得student用戶有執(zhí)行useradd命令的權(quán)限[root@desktop30Desktop]#vim

/etc/sudoers##Nextcomesthemainpart:whichuserscanrunwhatsoftwareon##whichmachines(thesudoersfilecanbesharedbetweenmultiple##systems).##Syntax:####

user

MACHINE=COMMANDS####TheCOMMANDSsectionmayhaveotheroptionsaddedtoit.####Allowroottorunanycommandsanywhereroot

ALL=(ALL)

ALLstudent

ALL=(ALL)

/usr/sbin/useradd

委派給student用戶有執(zhí)行useradd命令的權(quán)限修改了/etc/sudoers文件,賦予student有執(zhí)行useradd命令的權(quán)限[student@desktop30home]$useradd

234bash:/usr/sbin/useradd:Permissiondenied

為什么還是權(quán)限拒絕?[student@desktop30home]$sudo

useradd

234

權(quán)限委派在執(zhí)行的時候前面一定要加一個sudo命令,否則是無效的WetrustyouhavereceivedtheusuallecturefromthelocalSystemAdministrator.Itusuallyboilsdowntothesethreethings:#1)Respecttheprivacyofothers.

#2)Thinkbeforeyoutype.

#3)Withgreatpowercomesgreatresponsibility.[sudo]passwordforstudent:

輸入student用戶的密碼[student@desktop30home]$[student@desktop30home]$ls

234

student

student用戶創(chuàng)建用戶234成功,成功委派了用戶student有創(chuàng)建用戶的權(quán)限5771001803090012095579036822859633082577100180309001238657613739973576069657710018030

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論