av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

詳解restorecon命令使用方法

Linux restorecon命令如何使用?restorecon命令主要用途就是用來(lái)恢復(fù)SELinux文件屬性即恢復(fù)文件的安全上下文,下面為大家詳細(xì)講解一下restorecon命令使用方法。

網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)公司!專(zhuān)注于網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)站建設(shè)、微信開(kāi)發(fā)、微信小程序開(kāi)發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶(hù)創(chuàng)新互聯(lián)還提供了沿河免費(fèi)建站歡迎大家使用!

1.恢復(fù)文件的SELinux上下文

在以下示例中,index.html文件在SELinux上下文中具有“user_home_t”上下文類(lèi)型。這個(gè)上下文類(lèi)型,apache服務(wù)將無(wú)法訪問(wèn)。

[root@localhost ~]# ll -Z /var/www/html/index.html
-rw-rw-r--. root root unconfined_u:object_r:user_home_t:s0  13 Jan  7 11:14  /var/www/html/index.html

注意:上面的ls命令中的-Z選項(xiàng)將顯示特定文件的SELinux上下文。當(dāng)我們使用restorecon命令時(shí),我們實(shí)際上不需要知道文件的原始安全上下文。 restorecon會(huì)自動(dòng)修正。

以下示例將把index.html的安全性上下文恢復(fù)為適當(dāng)?shù)闹怠?如下所示,它已將SELinux上下文的類(lèi)型重置為“httpd_sys_content_t”, 現(xiàn)在apache將能夠?yàn)樵撐募峁┓?wù),而不會(huì)出現(xiàn)任何錯(cuò)誤。

[root@localhost ~]# restorecon /var/www/html/index.html
[root@localhost ~]# ll -Z /var/www/html/index.html
-rw-r--r--. 1 root root unconfined_u:object_r:httpd_sys_content_t:s0 13 Jan  7 11:14 /var/www/html/index.html

2.更改安全上下文時(shí)輸出信息

默認(rèn)情況下,執(zhí)行restorecon命令時(shí),它不會(huì)提示是否更改了文件的安全上下文。

[root@localhost ~]# restorecon -v /var/www/html/index.html
Relabeled /var/www/html/index.html from unconfined_u:object_r:admin_home_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0

3.使用通配符處理多個(gè)對(duì)象

下面實(shí)例將修改目錄下面所有文件的安全上下文。

[root@localhost ~]# restorecon -v /var/www/html/*

restorecon 命令使用實(shí)例restorecon 命令使用實(shí)例

4.遞歸處理文件和目錄

還可以使用-R選項(xiàng)遞歸重置文件的安全上下文。

[root@localhost ~]# restorecon -Rv /var/www/html/
Relabeled /var/www/html/sales from unconfined_u:object_r:admin_home_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0
Relabeled /var/www/html/sales/graph.html from unconfined_u:object_r:admin_home_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0

restorecon 命令使用實(shí)例restorecon 命令使用實(shí)例

5.根據(jù)輸入文件還原上下文

可以將需要恢復(fù)安全上下文的文件或文件夾路徑保存在文件里,使用-f選項(xiàng)指定文件,來(lái)恢復(fù)。在下面的/var/www/html/testdir目錄和下面的指定的文件需要恢復(fù)默認(rèn)安全上下文: 首先創(chuàng)建一個(gè)文件input.txt,在里面填入需要恢復(fù)默認(rèn)安全上下文的目錄或者文件的完整路徑。

[root@localhost ~]# vim input.txt
[root@localhost ~]# cat input.txt
/var/www/html/testdir
/var/www/html/testdir/file1.txt
/var/www/html/testdir/file3.txt
/var/www/html/testdir/file5.txt
/var/www/html/testdir/file7.txt
/var/www/html/testdir/file9.txt

下面使用restorecon來(lái)恢復(fù):

[root@localhost ~]# restorecon -Rvf input.txt
Relabeled /var/www/html/testdir from unconfined_u:object_r:admin_home_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0
Relabeled /var/www/html/testdir/file1.txt from unconfined_u:object_r:admin_home_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0
Relabeled /var/www/html/testdir/file2.txt from unconfined_u:object_r:admin_home_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0
Relabeled /var/www/html/testdir/file3.txt from unconfined_u:object_r:admin_home_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0
Relabeled /var/www/html/testdir/file4.txt from unconfined_u:object_r:admin_home_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0
Relabeled /var/www/html/testdir/file5.txt from unconfined_u:object_r:admin_home_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0
Relabeled /var/www/html/testdir/file6.txt from unconfined_u:object_r:admin_home_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0
Relabeled /var/www/html/testdir/file7.txt from unconfined_u:object_r:admin_home_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0
Relabeled /var/www/html/testdir/file8.txt from unconfined_u:object_r:admin_home_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0
Relabeled /var/www/html/testdir/file9.txt from unconfined_u:object_r:admin_home_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0
Relabeled /var/www/html/testdir/file10.txt from unconfined_u:object_r:admin_home_t:s0 to unconfined_u:object_r:httpd_sys_content_t:s0

6.排除某個(gè)目錄

還可以使用-e選項(xiàng)排除不需要恢復(fù)安全上下文的目錄。 在以下示例中,我們正在處理/var/www/html 目錄下的所有文件,但不包括/var/www/html/sales子目錄中的文件。

[root@localhost html]# restorecon -e /var/www/html/sales -Rv /var/www/html

還可以提供多個(gè)-e選項(xiàng)來(lái)排除多個(gè)文件或文件夾。


網(wǎng)頁(yè)名稱(chēng):詳解restorecon命令使用方法
本文網(wǎng)址:http://uogjgqi.cn/article/cccogoc.html
掃二維碼與項(xiàng)目經(jīng)理溝通

我們?cè)谖⑿派?4小時(shí)期待你的聲音

解答本文疑問(wèn)/技術(shù)咨詢(xún)/運(yùn)營(yíng)咨詢(xún)/技術(shù)建議/互聯(lián)網(wǎng)交流