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.
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?
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 ?
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.
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:
@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 @anon3337769 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.
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.
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.
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
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.
@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.
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.
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 / -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)
That script made for visual diff with Meld for .pacnew files by @jonathon kicks some serious butt!
#!/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