我是 Linux 的新手,因此需要了解有关此命令解释的详细信息
sudo bash -c 'for i in update {,dist-}upgrade auto{remove,clean}; do apt-get $i -y; done'
最佳答案
该命令可以分解为以下部分:
sudo
: 具有root权限bash -c '...'
: 使用 bash 执行用单引号括起来的命令,这是大多数 linux 发行版附带的标准 shell for i in update {,dist-}upgrade auto{remove,clean}; do ...; done
: 这是 bash 中的 for 循环。部分
update {,dist-}upgrade auto{remove,clean}
实际上是一个数组,其元素为 update, upgrade, dist-upgrade, autoremove, autoclean
, 和变量 i
将按顺序获取这些值中的每一个。您将在 advanced bash script guide 中获得更多信息. apt-get $i -y
: 最后执行的是什么。 i
是循环变量。 -y
表示默认回答是。您可以使用命令 man apt-get
找到更多信息。 . 所以基本上这个命令等价于下面的命令
sudo apt-get update -y
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
sudo apt-get autoremove -y
sudo apt-get autoclean -y
这是对系统中软件的完整升级和清理。
关于ubuntu - 有关此命令的详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52922985/