【Linux】兩個問題:root修改文件權限報錯Operation not permitted,解決rpm conflicts with file from package問題

一、root修改文件權限報錯Operation not permitted

[root@ yum.repos.d]# chmod 755 RedHat6.2.repo 
chmod: changing permissions of `RedHat6.2.repo': Operation not permitted

lsattr可用來查看文件的屬性:

lsattr RedHat6.2.repo
[[email protected]]# lsattr RedHat6.2.repo
----i--------e- RedHat6.2.repo

如果文件屬性中有i與a,或者有其中的一個

可以使用chattr去掉這屬性:
本機是i命令是chattr -i RedHat6.2.repo

chattr -ia RedHat6.2.repo

此時再次使用chmod命令即可更改文件的權限。

該方法對於文件目錄同樣適用,但是文件目錄使用lsattr命令查看屬性的時候並沒有反應,但是使用chattr命令去掉ia屬性之後,能夠成功使用chmod更改權限。

如果想要恢復ia屬性,使用:

chattr +ia RedHat6.2.repo

二、解決rpm conflicts with file from package問題

[root@harbor opt]# rpm -ivh python27-2.7.9-1.x86_64.rpm
準備中… ################################# [100%]
file /usr/bin/python2.7 from install of python27-2.7.9-1.x86_64 conflicts with file from package python-2.7.5-76.el7.x86_64
file /usr/share/man/man1/python2.7.1.gz from install of python27-2.7.9-1.x86_64 conflicts with file from package python-2.7.5-76.el7.x86_64
file /usr/bin/python2.7-config from install of python27-2.7.9-1.x86_64 conflicts with file from package python-devel-2.7.5-76.el7.x86_64
file /usr/include/python2.7/pyconfig.h from install of python27-2.7.9-1.x86_64 conflicts with file from package python-devel-2.7.5-76.el7.x86_64
方法一
yum -y remove python-2.7.5-76.el7.x86_64
卸載掉衝突的文件,安裝新的文件。如果由於由於依賴關係導致要卸載很多軟件,那可以優先考慮下一個方法。

方法二
rpm -ivh python27-2.7.9-1.x86_64.rpm --replacefiles
安裝的時候增加–replacefiles參數,但是不知道在yum裏如何實現。

–replacepkgs 強制重新安裝已經安裝的軟件包
–replacefiles 替換屬於其它軟件包的文件
rpm -e --nodeps python27-2.7.9-1.x86_64.rpm 強制刪除包

參考鏈接:
root權限下修改文件權限遇到 chmod: changing permissions of ‘***’: Operation not permitted
解決rpm conflicts with file from package問題

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章