Debian: debian_frontend=noninteractive

29/12/2020
Chưa phân loại
In this guide we’ll discuss the advantages of Debian’s configuration engine, how configuration dialogs work, how to reactivate them after use, and how to suppress them with the DEBIAN_FRONTEND=noninteractive environment variable.

An Introduction to Debian’s Configuration Engine

Debian’s package management system is easily Linux’s most popular, powering Debian, Ubuntu, Linux Mint, MX Linux, and a host of other Debian-derivatives. The DEB package format contains far more than just the software binary files. It contains a wide assortment of control files that tell the package manager about software dependencies, start and stop instructions for daemon control, versions, license, authors, and a digital signature to guarantee integrity and authenticity.

These control files can be setup by the software publisher or maintainer to prompt the user for important configuration variables. These options save the user considerable time by keeping them from the sometimes tedious task of editing possibly multiple configuration files. If you’re a frequent user of Debian or its derivatives, you have probably seen screens (either text or graphical) asking for configuration details after installing a new or updated package.

Configure it Again, Apt

These scripts just aren’t meant for install time, either. If you wish to reconfigure the package, you can run:

dpkg-reconfigure package-name

Where package-name is the name of the package. If a configuration profile is present, you will be presented with those options again and given a chance to make changes.

For example, on a new Debian install, I run:

dpkg-reconfigure console-setup

To configure the text terminal console font, size, and character set. It’s far easier than setting these items manually.

Automation, Automation, Automation

Configuration prompts are great if you are interacting as a knowledgeable user, but in some cases, particularly in automation or scripting, you don’t want to prompt the user at all. In this case, quieting the configuration prompts is likely advantageous. To do this, run your apt command with the environment variable specified before it.

DEBIAN_FRONTEND=noninteractive apt-get -q -y install postfix

In this case, all configuration questions will be prompted and either the default selected (if specified), or, if not provided, no configuration will be performed on the package. The -q switch prevents messages from being displayed, and the -y switch answers yes to perform the installation or upgrade unattended.

To make the environment variable persist for your session, run:

export DEBIAN_FRONTEND=noninteractive

Once you log out or exit your shell, the environment variable will disappear or reset to the default. If you want to set it permanently, you can add it to your .bashrc or .zshrc file, however I don’t recommend this because you may miss important configuration questions in the future. That said, if you intend for the Debian system to never require user configuration, this may be desirable.

Preserving Configuration Files

During package installation or upgrade, Debian may wish to prompt the user on overwriting a configuration file. This preference can be appended to the installation command.

apt-get install -q -y
-o Dpkg::Options::="–force-confdef"
-o Dpkg::Options::="–force-confold"
postfix

In this command, the installer is told to quiet any messages, assume yes, and then upgrade configuration files if no changes are present in the new package. If a previous configuration file is present, create a new file and don’t overwrite the old one.

If you don’t care about the configuration file and want to overwrite it, you can use:

apt-get install -q -y -o Dpkg::Options::="–force-confnew" postfix

Take care when using this option If you’re not absolutely certain that you don’t need the existing configuration and something goes wrong, you can create significant issues on your system or lose access to a remote system upon reboot or service restart.

Changing the Frontend

Though the primary purpose of this article is to explain the noninteractive switch, there are other parameters you can specify for DEBIAN_FRONTEND.

noninteractive

Do not ask any questions and assume the defaults.

dialog

Presents the user with the familiar text gray window on blue background. This is the default.

text

This removes the dialog interface and asks the configuration questions in a pure text-based format. This is well suited for slow connections or terminal emulators that don’t cooperate well with the dialog-based input and windowing system.

gtk

Prompts the user graphically using the GTK libraries. This may not work correctly on KDE. Also requires the package cdebconf-gtk and gkdebconf to be installed before use.

Conclusion

I hope this guide has helped you with your system administration and automation tasks through use of the DEBIAN_FRONTEND environment variable.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Install Linux Mint Cinnamon

Within the maze of Linux distributions, Linux Mint is one of the top ones. Personally, I love Linux Mint. Linux Mint is...
29/12/2020

Browser Automation Using Selenium (Python)

SELENIUM is a web based & open source tool which is used to control the web browser through many programming languages....
29/12/2020

Manjaro vs Arch Linux Distribution Comparison

If you’ve looked at the DistroWatch Page Hit Ranking statistics in recent months, you might have noticed that the top...
29/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn
03/06/2024

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh
03/06/2024

Mua proxy Onet uy tín tại Onet.com.vn
03/06/2024

Thuê mua IPv4 giá rẻ, tốc độ nhanh, uy tín #1
28/05/2024

Thuê địa chỉ IPv4 IPv6 trọn gói ở đâu chất lượng, giá RẺ nhất?
27/05/2024