Ubuntu 18.04 で apt-get したときの対話画面をスキップする

※2022年1月10日 現在では非推奨です

結論

  • apt-get dist-upgrade の場合です
$ DEBIAN_FRONTEND=noninteractive sudo -E apt-get dist-upgrade -y

状況

grub-pc などで以下のような画面が出て対話が必要なときがあります。これを避けたい場合です。

f:id:gregminster:20190113142137p:plain

根拠

$ man sudo
(前略)
       -E, --preserve-env
                   Indicates to the security policy that the user wishes to
                   preserve their existing environment variables.  The security
                   policy may return an error if the user does not have permission
                   to preserve the environment.
(後略)

補足

Ubuntu 16.04 以降が対象だと思います。

参考

Powered by はてなブログ