1. 程式人生 > >not syncing: Attempted to kill init解決辦法

not syncing: Attempted to kill init解決辦法

配置FTP服務的時候,修改了selinux引數。修改/etc/selinux/config中的SELINUXTYPE=targeted修改為Disable。導致 linux系統不能啟動。

出現錯誤 Kernel panic -not syncing:Attempted to kill init!

網上查詢,有人遇到相同問題,解決方案如下:

在linux啟動介面出現時,按f2進入如下介面:

按e進入如下介面
移動到第2個選項,再按e進入編輯

在後面輸入 selinux=0

按回車。
返回到原來介面

再按b,就可以啟動了。

SELINUX從理解到動手配置。

SELinux 可以為你的系統提供較棒的安全防護。 使用者能被分配預先定義好的角色,以便他們不能存取檔案或者訪問他們不擁有的程式。

Selinux的啟用與關閉

編輯/etc/selinux/conf檔案

SELINUX=enforcing(強制:違反了策略,你就無法繼續操作下去)

Permissive(有效,但不強制:違反了策略的話它讓你繼續操作,但是把你的違反的內容記錄下來)

Disabled(禁用)

禁用的另一種方式:在啟動的時候,也可以通過傳遞引數selinux給核心來控制它

編輯/etc/grup.conf

title Red Hat Enterprise Linux Server (2.6.18-8.el5)

root (hd0,0)

kernel /vmlinuz-2.6.18-8.el5 ro root=LABEL=/ rhgb quiet selinux=0

initrd /initrd-2.6.18-8.el5.img

SELINUXTYPE=targeted

此引數可選項:targeted和strice。分別是targeted只控制關鍵網路服務,strice控制所有的服務

查詢selinux的狀態

[[email protected] ~]# /usr/sbin/getenforce

Enforcing

[[email protected] ~]# sestatus -bv

SELinux status: enabled

SELinuxfs mount: /selinux

Current mode: enforcing

Mode from config file: enforcing

Policy version: 21

Policy from config file: targeted

檢視selinux載入的核心模組

[[email protected] selinux]# semodule -l

amavis 1.1.0

ccs 1.0.0

clamav 1.1.0

dcc 1.1.0

evolution 1.1.0

iscsid 1.0.0

mozilla 1.1.0

mplayer 1.1.0

nagios 1.1.0

oddjob 1.0.1

pcscd 1.0.0

pyzor 1.1.0

razor 1.1.0

ricci 1.0.0

smartmon 1.1.0

檢視selinux錯誤日誌

[[email protected] selinux]# sealert -a /var/log/audit/audit.log

SElinux的圖形化管理工具

[[email protected] selinux]# system-config-selinux

Selinux的基本操作

檢視檔案:ls –Z(--context)

[[email protected] ~]# ls -Z

drwx------ root root root:object_r:user_home_t Desktop

-rw------- root root system_u:object_r:user_home_t anaconda-ks.cfg

-rw-r--r-- root root root:object_r:user_home_t install.log

-rw-r--r-- root root root:object_r:user_home_t install.log.syslog

[[email protected] ~]# ls --context

drwx------ root root root:object_r:user_home_t Desktop

-rw------- root root system_u:object_r:user_home_t anaconda-ks.cfg

-rw-r--r-- root root root:object_r:user_home_t install.log

-rw-r--r-- root root root:object_r:user_home_t install.log.syslog

檢視檔案系統的擴充套件屬性:getfattr

[[email protected] ~]# getfattr -m. -d /etc/passwd

getfattr: Removing leading '/' from absolute path names

# file: etc/passwd

security.selinux="system_u:object_r:etc_t:s0\000"

檢視的檔案的 security.selinux 屬性中儲存了此檔案的安全上下文, 所以上面例子中的上下文就是 system_ubject_r:etc_t 。

所有運行了SE Linux的ext2/3檔案系統上都有 security.selinux 這個屬性。

更改檔案的擴充套件屬性標籤:chcon (不能在 /proc 檔案系統上使用,就是說 /proc 檔案系統不支援這種標記的改變。)

[[email protected] test]# ls --context aa.txt

-rw-r--r-- root root root:object_r:user_home_t aa.txt

[[email protected] test]# chcon -t etc_t aa.txt

[[email protected] test]# ls --context aa.txt

-rw-r--r-- root root root:object_r:etc_t aa.txt

恢復原來的檔案標籤: restorecon

[[email protected] test]# restorecon aa.txt

[[email protected] test]# ls -Z aa.txt

-rw-r--r-- root root user_u:object_r:user_home_t aa.txt

顯示當前使用者的Selinux context

[[email protected] ~]# id -Z

root:system_r:unconfined_t:SystemLow-SystemHigh

runcon 使用特定的context來執行指令

[[email protected] ~]# runcon -t user_home_t cat /etc/passwd

root:system_r:user_home_t:SystemLow-SystemHigh is not a valid context

檢視某種服務是否受到SELinux的保護

[[email protected] ~]# getsebool -a (RHEL4:inactive受保護,active不受保護;RHEL5:off受保護,on不受保護)