我可以配置 Ubuntu 以删除 apt-get 和 dpkg 吗?

我可以配置 Ubuntu 以删除 apt-get 和 dpkg 吗?

我需要完全删除任何更改系统的方法。有没有办法删除 apt-get 和 dpkg?是否还可以禁止更改复制到系统中的任何文件的可执行位?可以使用掩码来完成此操作吗?

答案1

apt-get您可以从和中删除执行位dpkg

chmod -x $(which apt-get)
chmod -x $(which dpkg)

请注意,这将禁用更新。此外,您还可以以只读方式安装驱动器

答案2

我认为随着使用 LXC 和 Docker 的功能性“微”部署的出现,这可能会变得越来越重要。

我可以想到为什么要在容器中创建 bash 环境、在其中放置需要以 root 身份运行的实用程序、通过以特权模式启动容器来使各种设备可供容器使用,但不希望该容器的用户添加任何新软件。

随着容器的分层修订,那么“一旦删除就无法恢复”就不正确了。我可以迭代我的docker实用程序容器,但以“最终”形式交付它。

使用风险自负(除了在 docker 风格的工作中,我不建议这样做):至少在 Precise 中,你可以使用 apt-get remove apt 来导致下面的交互:

apt-get remove apt 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  apt ubuntu-minimal
WARNING: The following essential packages will be removed.
This should NOT be done unless you know exactly what you are doing!
  apt
0 upgraded, 0 newly installed, 2 to remove and 57 not upgraded.
After this operation, 3300 kB disk space will be freed.
You are about to do something potentially harmful.
To continue type in the phrase 'Yes, do as I say!'
 ?] Yes, do as I say!

(当然,现在如果 scp 或其他文件传输程序可用于容器,那么有人可以将其全部重新摆弄回去。)

相关内容