I have seen that grub2 configuration files exist in so many different locations.
/etc/grub.d/etc/default/grub/boot/grub2/grub.cfg
Can anyone tell me the purpose of each directory/file?
41 Answer
/etc/default/grub is where you can set simple options for many GRUB settings. It is parsed as a shell script.
/etc/grub.d contains shell scripts which generate GRUB configuration (based on settings on /etc/default/grub). update-grub (aka grub-mkconfig) runs these scripts to generate actual GRUB configuration.
/boot/grub2/grub.cfg is where the generated configuration is saved for GRUB to use.
Ordinarily, for setting GRUB options, you edit /etc/default/grub. If you need to generate additional GRUB entries or alter the entries generated, then add or change scripts in /etc/grub.d. Don't manually edit /boot/grub2/grub.cfg.