[HowTo] handle some Pacnew files best

Many users struggle with handling .pacnew files. Mishandling them can have far-reaching consequences. Many people avoid these files for fear of doing something wrong. This, however, leads to problems in the long run.

Objectives:

To demonstrate which pacnew files are dangerous and how best to handle them.

/etc/default/grub

This file determines how GRUB will be configured. For example, it specifies whether GRUB is visible or hidden at boot. However, it only takes effect when grub.cfg actually needs to be regenerated. This happens, for example, with every kernel update.

Carefully compare the old and new files and copy as much as possible from the new file without changing your existing configuration. If you’re unsure about a line, ask someone who knows about this in the forum.

/etc/default/useradd

Just copy the .pacnew over the existing file.

/etc/hosts

The hosts file is important for local name resolution. Do not simply replace it with hosts.pacnew!

  • Delete hosts.pacnew without copying it.

or

  • Copy the first lines (starting with # ) from hosts.pacnew into your existing hosts file, replacing the other first lines (with #). Then delete hosts.pacnew.
/etc/locale.gen

The installer of manjaro asked you about your locale and set it. The locale package is obviously unaware of this and offers a neutral or english only locale. So for non-US people, you will probably have all lines in this file commented, and a last section ending in

# Locales enabled by Calamares
de_DE.UTF-8 UTF-8
en_US.UTF-8 UTF-8

As you see in this example German is also uncommented. And i want it to remain that way
In 99% of cases, you should discard this .pacnew file. The exception is if your language has just been added (congratulations!). If you ever make changes to this file, you will need to regenerate the locales afterward using sudo locale-gen.

/etc/makepkg.conf.d/fortran.conf /etc/makepkg.conf.d/rust.conf

Just copy the .pacnew over the existing file.

/etc/mkinitcpio.conf

Please note that this file is extremely important. It helps create the contents of the initramdisk so your computer can boot. You can find suitable instructions in the ARCH Wiki. Read the relevant text carefully!

If you are unsure, it’s best to ask someone who knows about this in the forum. You may also have a look at: Manjaro-pacnew-checker: Help to understand /etc/mkinitcpio.conf.pacnew - #2 by cscs

If you make any changes, be sure to take notes. The effects of changes are not immediately visible, but only after the initramdisk has been regenerated, and then only after a reboot.

sudo mkinitcpio -P

If you use btrfs with compression, please select COMPRESSION=cat

/etc/passwd

Under no circumstances should you ever edit the passwd file. You’ll kick yourself out of the system if something goes wrong.

  • Be sure to delete passwd.pacnew

The path of the root user’s shell is now /usr/bin/bash instead of /bin/bash . You could change this in the real /etc/passwd — because it may still have /bin/bash for the root’s shell — but please be really careful.

/etc/shells

The shells file specifies which command interpreters (shells) are used and where they are located. If you corrupt this file, you’ll completely crash the system. If you edit it, you must be especially careful.

  • Leave your shells file unchanged and delete shells.pacnew.

or

  • Only add lines from shells.pacnew to your existing shells file if they are missing from the existing file. As a precaution, do not delete any of the existing lines (especially those ending with /sh, /bash, or /zsh).
/etc/sudoers

The /etc/sudoers file is extremely important for users to perform administrative tasks. If it becomes corrupted, it may no longer be possible to maintain the system.

Before making changes to this file, it’s better to ask someone who knows something about it. In case changes shall be made use visudo command.

  • Currently, it seems safest to keep the existing file and delete the pacnew.
/etc/ssh/sshd_config

This file is used for the basic configuration of the SSH daemon. If it is corrupted, you may no longer be able to access this machine via SSH. If you have direct access to this machine (e.g., via keyboard), not much can happen.

  • Apply the changes from sshd_config.pacnew. to your existing sshd_config. Be careful not to delete any lines that you yourself created in sshd_config for whatever reason.

Please be careful not to confuse the two files ssh_config and sshd_config.

/etc/...

Please do not answer to this topic, but insert aditional sections into this post. :wink:

13 Likes

My 2 cents: i think it will be good to add that there is a small gui notifier about pacnews - manjaro-pacnew-checker. Also worth noting is the correct way to check and handle pacnew files manually, so that is easy and safe and does not destroy their permissions. pacdiff -s is the only safe option, it will invoke sudo if needed. To have a graphical editor, install meld. Then the command will become:

DIFFPROG=meld pacdiff -s

After that, always choose the View option. Make changes to one of the files (careful, each file has its own save button!), close meld, the prompt will come again and you can discard the file that is no longer needed.

After that general instructions, looking at my grep ".pacnew" /var/log/pacman.log the more important files i see in addition the the above are maybe…i will add above.

6 Likes

If pacman-contrib and meld are installed,

DIFFPROG=/usr/bin/meld

could be added to the file /etc/environment.

Then a user only needs to remember the commands

$ pacdiff -o

to identify pacnews and

$ pacdiff -s

to merge them.

4 Likes