久久ER99热精品一区二区-久久精品99国产精品日本-久久精品免费一区二区三区-久久综合九色综合欧美狠狠

博客專欄

EEPW首頁(yè) > 博客 > fakeroot

fakeroot

發(fā)布人:電子禪石 時(shí)間:2020-12-23 來(lái)源:工程師 發(fā)布文章
fakeroot簡(jiǎn)介

fakeroot ubuntu manpage的解釋如下

fakeroot - run a command in an environment faking root privileges for file manipulation1

fakeroot建立一種環(huán)境,在里邊運(yùn)行的命令可以以假的root權(quán)限操作文件。 讀完上面這一句還是不太明白它有什么用,到底怎么用。
下面又有一句

This  is useful for allowing users to create archives (tar, ar, .deb
       etc.) with files in them with root permissions/ownership.  Without fakeroot one would need
       to  have  root privileges to create the constituent files of the archives with the correct
       permissions and ownership, and then pack them up, or  one  would  have  to  construct  the
       archives directly, without using the archiver.12345

它主要用來(lái)打包或者用來(lái)生成image,假如沒(méi)有fakeroot,要做具有root權(quán)限文件的包的話,需要做的事情既多又麻煩, 首先切換到root權(quán)限,修改目錄中所有文件為root權(quán)限,打包, 完了之后還需要把權(quán)限改回來(lái)。
有fakeroot就很方便了,在fakeroot環(huán)境中,只需要做打包動(dòng)作,里邊的所有文件自動(dòng)的都是root權(quán)限。

fakeroot使用

rootfs目錄是一份根文件系統(tǒng)目錄,它的用戶和組是本機(jī)登陸用戶
在這里插入圖片描述
進(jìn)入fakeroot環(huán)境,文件的owner和group自動(dòng)變?yōu)閞oot。 exit 退出fakeroot, 文件的owner和group還原。
退出fakeroot后就返回普通用戶狀態(tài),fakeroot只在運(yùn)行過(guò)程中起作用。
在fakeroot中打包
在這里插入圖片描述
可以看到包內(nèi)的uid和gid是root用戶的id。
所以這份image使用時(shí)他內(nèi)部文件的權(quán)限就是root權(quán)限。

fakeroot的一般用法是fakeroot – script, script是shell腳本,把需要再root權(quán)限執(zhí)行的命令寫在腳本里邊。
參考
https://blog.kghost.info/2011/02/11/使用fakeroot模擬root權(quán)限執(zhí)行程序/


*博客內(nèi)容為網(wǎng)友個(gè)人發(fā)布,僅代表博主個(gè)人觀點(diǎn),如有侵權(quán)請(qǐng)聯(lián)系工作人員刪除。

模擬信號(hào)相關(guān)文章:什么是模擬信號(hào)


晶振相關(guān)文章:晶振原理


關(guān)鍵詞:

相關(guān)推薦

技術(shù)專區(qū)

關(guān)閉