ubuntu - 有关此命令的详细信息

标签 ubuntu terminal

我是 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/

    相关文章:

    c - Gtk 在单击按钮时更改多个标签

    Bash on macOS - 获取给定年份每个星期六的日期列表

    linux - 在终端中自定义多个选项卡

    linux - 在 vim 中编码时如何使用终端?

    powershell - VS Code 从 powershell 打开新终端

    mysql - ubuntu和mysql备份网络服务器的解决方案?

    linux - 使用scala进程运行相关Ubuntu命令

    ubuntu - lein repl 中的 Control-d 行编辑?

    php - 在 php.ini 中找不到 tmp 文件夹。 (Ubuntu 10.10, apache2)

    go - 在命令行上使用 Go,如何隐藏来自用户终端的命令行输入?