Trying to understand .pacnew files

Hi all,

I’m trying to make myself prepared and capable for dealing with .pacnew files when the need arises.

This is the understanding I got from googling:

  • I can use vimdiff to merge the two configuration files eg. vimdiff /etc/pacman.conf /etc/pacman.conf.pacnew

  • Then apply changes to the old config file: a. add stuff to old which has been added to .pacnew, b. delete stuff from old which isn’t present in .pacnew, modify stuff in old which has been modified in .pacnew`

I have three questions.

  1. Is it the case that I would basically just have to analyse both the files and make the current config file exactly the same as the .pacnew file except for my own modifications?

  2. after merging the .pacnew file into the current config file using the above example would it be okay to run sudo rm /etc/pacman.conf.pacnew ?

  3. Is there anything that I’m missing?

This would be the worst you can do, it could make your system unbootable for some config files :scream:

1 Like

glad I’m clarifying ahead of time.

Maybe you misunderstood the wording?

Is it not correct that the current config file needs to be made exactly the same as the .pacnew file? How would you answer my first question?

lol BTW Leon is one of my favourite classic films

Not really. What to do is highly situational. It really depends on what the file is and what changed. In some situations they should be ignored, in some cases you can overwrite the old with the new and some require manual merging.

Yes, you can remove them if you don’t need them

2 Likes

Something I posted in another thread; forgive me for quoting rather than re-typing everything.

4 Likes
  1. Depends but most of the time you can i guess…
  2. Yes you can
  3. I guess not.
    If you didn’t change anything in the config file, you can as well delete the current one and just rename the .pacnew (e.g. pacman.conf.pacnew -> pacman.conf)

Of course you also can do it the other way around. Take the .pacnew file and merge your changes into the pacnew file. Then delete your current one and rename the .pacnew (as mentioned above).

I use meld to compare the two files.

@jonathon shared a nice script in another thread here. Just a little helper - it also calls meld for comparing:

1 Like

Thank you all for your replies.

@dalto I don’t need pacmerge do I, if I’m going to use vimdiff?

I get that… lol I think. My question 1) is related to the situation whereby there is a config file which I’ve modified so it’s different from the original and the .pacnew is different from both the original and the current config file. So in that situation where manual intervention is necessary and it’s not a file @tardy mentioned would my question 1) be correct.

lol sorry trying to get clarification and explain my understanding is a bit long winded.

@T-Flips I could also mv the file couldn’t I? Am I correct in thinking that if I for example sudo mv /etc/pacman.conf.pacnew /etc/pacman.conf that would overwrite the pacman.conf file? so which ever one I make the changes to I can just use that one to overwrite the other one and then delete whatever is not needed.

1 Like

Correct; you will want the file to end up incorporating any new changes that the pacnew brings, plus any specific modifications that you made in the old file.

A lot of times, it’s just syntax in the comments that has changed in a pacnew. Other times, it’s a more serious change.

Sometimes it’s easier to merge, sometimes it’s easier to manually make a change or two.

I don’t think there’s really a “one-size-fits-all” approach that works best in all instances, but you seem to have a good grasp of the principles.

You might want to get into the habit of saving your old config files (for example, add .bak at the end to signify a backup), and maybe saving the pacnew files, too (copy them, and append the extension - or copy them to another location). This would make it simpler to revert changes if needed, and try again.

3 Likes

Yeah I saw someone on Youtube doing that and I started doing it.

Okay thanks for all the help :smile:

I’m assuming that’s why @dalto showed me pacmerge. I’ll just have to be patient and wait to try and practice doing it.

Will this post stay on this forum permanently so I could refer back to it?

1 Like

Yes/no/maybe. It is fairly unanswerable because there are different types of files and what to do varies.

For me, I delete or ignore pacnew files 90% of the time. It is typically not anything worth dealing with.

However, sometimes it is. What you need to look out for is when software makes a material change to a config file format or has some other major functionality change that requires new config. However that is relatively rare.

Yes, it should.

3 Likes

Exhaling breath. I’ll probably be back here again trying to confirm or clarify how to deal with a .pacnew file. I’ll try and find out what I should do first obviously.

@dalto I will look out for the changes you mentioned and probably just ask for clarification that I’m doing things correctly.

Thank you

hahaha obviously I wanted that one time fits all answer so as to be prepared and fully capable of dealing with .pacnew files

1 Like

What makes this conversation complicated is dealing with it in the abstract without a concrete example.

I think you will find that in most cases it is actually pretty obvious what needs to be done and when it isn’t you can always ask.

3 Likes

Enough said @dalto you’ve put me at ease, massive thanks as always.

It’s quite strange, I’m 38 yrs old but never have I felt like calling someone a friend who I don’t even know. lol

But honestly I’ve thought that a lot on this forum talking to different people

2 Likes

No. In most cases your existing, old config file will work just fine. The pacnew file might contain new config options which you do not have in your old config. But typically these new config options are set to default values in the pacnew file anyways. So that it doesnt matter if they do not exist in your old config file. The application will also use default values in that case.

By the way, instead of vimdiff I am using meld, a graphical diff tool, to compare files and to easily work on them. The tool can transfer different lines from file A to B with just a mouse click.

5 Likes

@mbod thank you. I will be going back over this post tomorrow taking notes. I think someone else has mentioned meld too, I’ll definitely check it out thank you very much.

:+1:

there can be new listings or some old…mostly i dont fred to much on pacnew myself…

there can be new lines for new function but if you dont use it , i let it be as it is…

3 Likes

I came across .pacnew yesterday when I was reading a post on reddit (or somewhere) and someone mentioned that Arch is stable as long as you deal with .pacnew. I suppose that’s what got me concerned with the issue.

All your comments and explanations have been very helpful indeed. :smile:

I could be wrong because it’s only theoretical for me at this point, but really I feel much better about this issue at the moment. hoohaa!

WARNING: you may not want to read past this line, this is just me with my overly meticulous way of learning.

  • There are a few files that you should always leave alone unless there are specific instructions to merge with a pacnew. These files include: passwd shadow gshadow group The pacnews for the aforementioned files will basically just be empty defaults; the ones on your computer have your user and password information, so you never want to overwrite them. Unless specifically instructed (via the Arch news page) to do otherwise, the best action for these pacnew files is to simply delete them.

  • Tools to be used: meld, pacmerge and vimdiff.

  • warning: /etc/pam.d/usermod installed as /etc/pam.d/usermod.pacnew (look out for these types of warnings when doing an update)

  • If I installed throttled and modified the config file then updated throttled and the new config file with the update was different from the original and different from the current one I had previously modified then the new config file would get saved with a .pacnew extension. I would need to manually merge the new .pacnew config file with my current one if software makes a material change to the config file format or has some other major functionality change, (copy and paste the lines of code). This way I get the updated config file but I leave the changes I made in place too. Then I can sudo rm the .pacnew file

  • A lot of times, it’s just syntax in the comments that has changed in a .pacnew file. Other times, it’s a more serious change.

  • I can use vimdiff to merge two configuration files eg. vimdiff /etc/pacman.conf /etc/pacman.conf.pacnew apply changes to the old config file: a. add stuff to old which has been added to .pacnew, b. delete stuff from old which isn’t present in .pacnew, modify stuff in old which has been modified in .pacnew.

  • Basically make the old config file exactly the same as the .pacnew file except for my own additions. (This is not always the case @dalto mentioned, it works with a case by case situation. In some situations they should be ignored (just delete the .pacnew file) in some cases you can overwrite the old with the new and some require manual merging.)

  • After I have saved the changes into the old config file I can do sudo rm /etc/pacman.conf.pacnew

  • If I fixed, made changes to the current config file then I can just rm the .pacnew file. If I fixed or made changes to the .pacnew then I can mv the .pacnew to the current config file to overwrite it and then rm the .pacnew file. (I think this is the case, best to confirm or test it with a timeshift backup ready.)

  • To keep the modifications that I have made in the current config file I will have to know what those changes are. Get into the habit of saving your old config files (for example, add .bak at the end to signify a backup), and maybe saving the pacnew files too, (copy them, and append the extension - or copy them to another location). This would make it simpler to revert changes if needed, and try again.

  • find /etc -r egextype posix-extended -regex ".+\.pac(new|save)" 2> /dev/null

  • find / -regextype posix-extended -regex ".+\.pac(new|save)" 2> /dev/null (both of these commands will search the system for .pacnew files either in /etc or in root, meaning the entire system)

  • sudo pacman -Rn (will result in no .pacsave files being saved)

1 Like

yeah that’s correct

1 Like

i would not overwrite the pacnew to the orginal…

you can use pacdiff with meld , to check the differences what is added on or not…

like new mirrors , mayby you had a good mirror file but then you have a bad mirror choice as example

… better to look wat differences are most time you dont need to change a la minute…

if you look mkinitcpio pacnew and the thing what you used the “” and the () different; but you have to understand the changes a bit before you do that

1 Like

That script made for visual diff with Meld for .pacnew files by @jonathon kicks some serious butt! :partying_face:

#!/usr/bin/bash
set -euo pipefail
export PATH=/usr/bin:/usr/sbin

for i in $(/usr/bin/pacdiff --output); do
    echo "Merging $i ..."
    /usr/bin/meld "admin://$i" "admin://${i/.pacnew/}";
done
2 Likes