今天在Ubuntu服務(wù)器上安裝supervisor翅睛,部署沒成功想卸載重來铐殃,sudo apt-get remove supervisor
后發(fā)現(xiàn)配置文件還在,便手動(dòng)刪除了配置文件。再次安裝之景,提示配置文件不存在铲汪,WTF熊尉!配置文件不該你軟件給我創(chuàng)建嗎?我想掌腰。
查閱資料才知狰住,還有 apt-get purge
這一選項(xiàng),purge 清除齿梁。
劃重點(diǎn):
apt-get remove 會(huì)刪除軟件包而保留軟件的配置文件
apt-get purge 會(huì)同時(shí)清除軟件包和軟件的配置文件
但是為什么重新安裝會(huì)失敗呢催植?
系統(tǒng)中存在dpkg這么一個(gè)工具,會(huì)記錄軟件包的狀態(tài)勺择,不只是安裝和未安裝兩種狀態(tài)创南,會(huì)記錄以下這些狀態(tài):
not-installed - The package is not installed on this system
config-files - Only the configuration files are deployed to this system
half-installed - The installation of the package has been started, but not completed
unpacked - The package is unpacked, but not configured
half-configured - The package is unpacked and configuration has started but not completed
triggers-awaited - The package awaits trigger processing by another package
triggers-pending - The package has been triggered
installed - The packaged is unpacked and configured OK
當(dāng)執(zhí)行apt-get install
時(shí),apt軟件包管理工具會(huì)先檢查要安裝的軟件的狀態(tài)省核,向我這種情況下稿辙,手動(dòng)刪除了軟件配置后,并不會(huì)引起dpkg中記錄的狀態(tài)的改變气忠,即仍為 config-files 狀態(tài)邻储,所以安裝過程會(huì)直接跳過創(chuàng)建配置文件這一過程赋咽。于是當(dāng)軟件想要啟動(dòng)進(jìn)程的時(shí)候,才發(fā)現(xiàn)找不到文件吨娜。
所以當(dāng)你想徹底地刪除軟件包的時(shí)候脓匿,用 apt-get purge
吧
原文:http://bencane.com/2014/08/18/removing-packages-and-configurations-with-apt-get/