Updating packages: whether to update the config file
February 8, 2023
Consider a situation when the package manager of your Linux distribution (Debian, Linux Mint, Ubuntu, Kali Linux) asks about updating the configuration file – what to do and how to get the latest version of the configuration file? Let’s figure it out.
With some updates of some packages, the structure of the configuration file changes. As a rule, the new file contains directives and settings that are necessary for the new version of the program, without which it cannot work.
Setting up a services is almost always changing configuration files. The end file can be the result of lengthy configuration work and many tests. This can take hours or even days.
Therefore, if it is necessary to update the configuration, a dilemma arises:
- do not update the config, as a result of which the new version of a package will not work normally
- update config and erase service configuration results
It is for this reason that the system asks you every time what needs to be done if the configuration file is updated with the program update?
An example of a message in which the package manager asks what to do with the new config file:
Configuration file '/etc/squid/squid.conf' ==> Modified (by you or by a script) since installation. ==> Package distributor has shipped an updated version. What would you like to do about it ? Your options are: Y or I : install the package maintainer's version N or O : keep your currently-installed version D : show the differences between the versions Z : start a shell to examine the situation The default action is to keep your current version. *** squid.conf (Y/I/N/O/D/Z) [default=N] ?
The options are:
- Y or I – install a new config file
- N or O – save the currently used config file
- D – show differences between versions
- Z – open the shell to examine the situation
The default option is to save the current config file (N).
If in reality you have not used this program, or the settings made are of no value to you, then always agree to update the configuration file. If the settings made are important to you, then:
- refuse to update the config file
- make a backup copy of your config, update the config file to the new version, and then make the necessary settings in it
For some packages, like Tor, the config file is just a set of comments with no setting active – for such files (if you haven't changed them), the update is more of a formality.
Another option for reporting a new version of the configuration file:
Package configuration ┌──────────────────────────────────┤ Configuring privoxy ├──────────────────────────────────┐ │ A new version (/etc/privoxy/config.ucftmp) of configuration file /etc/privoxy/config is │ │ available, but the version installed currently has been locally modified. │ │ │ │ What do you want to do about modified configuration file config? │ │ │ │ install the package maintainer's version │ │ keep the local version currently installed │ │ show the differences between the versions │ │ show a side-by-side difference between the versions │ │ show a 3-way difference between available versions │ │ do a 3-way merge between available versions │ │ start a new shell to examine the situation │ │ │ │ │ │ <Ok> │ │ │
By default, the option “keep the local version currently installed” is selected. This is the best option if you want to keep your previous settings. To continue updating packages, press the “Tab” key, as a result you will switch to the “<Ok>” button.
And press the “Enter” key.
If you do not want to save the settings you made earlier, but want to get a new version of the configuration file, then use the cursor keys to select the “install the package maintainer's version” option. Then press “Tab” and “Enter” again.
Should I update configuration files in the /etc/default/ directory
A special case, in my opinion, is the /etc/default/ directory.
For example, the following screenshot shows that a request is being made to update the /etc/default/grub file.
As the name of the directory itself implies, it contains default configuration files, which, most likely, do not change even if you configured a particular service or program.
Therefore, by default, these configuration files can be updated, except in special cases when you specifically make changes to them.
How to view the new config file
Typically, system administrators and users save the current configuration file. But how do you view the new file? After all, it is quite possible that there are important changes in it.
One way to do this is to download the latest version of a package and see the configuration file for the latest version in that package.
Download the package with a command like:
apt download PACKAGE
For example, to download the squid package
apt download squid
Unpack the downloaded installation file with a command like:
ar x FILE.deb
ar x squid_5.1-2_amd64.deb
Now we need to unpack a file called data.tar.gz or data.tar.xz.
Look at the contents of the folder to find out the name of the file:
If the file has a .tar.gz extension, then the command is as follows:
tar xzf data.tar.gz
If the file has the extension .tar.xz, then the command is as follows:
tar xf data.tar.xz
Let's check the contents of the current directory again in search of unpacked folders and files:
Configuration files on the system are usually placed in the /etc/ directory, when you unpack the package, you will find this folder under the path ./etc/ (that is, in the current folder).
For example, the command to view the configuration file of the latest version of the squid package I am interested in:
- Warning: apt-key is deprecated (SOLVED) (100%)
- How to simulate package installation on Linux (How to create and install a dummy package) (100%)
- Is it safe to remove configuration files left over from removed packages? (SOLVED) (82.2%)
- dpkg: error: fgets gave an empty string from '/var/lib/dpkg/triggers/Unincorp' (SOLVED) (82.2%)
- Do services need to be restarted when updating packages (73.8%)
- How to add text to images in ImageMagick (RANDOM - 50%)