I know that GRUB kernel boot parameters, for example panic=-1 can be added by sudo nano /etc/default/grub and then sudo update-grub.

My application comes with a setup.sh shell script that sets everything up for the user, as I want it to be able to be used by the non-technically minded user. Anyway, a driver called intel_pstate makes my app not work, so on devices where intel_pstate is detected, I want the setup.sh file to add intel_pstate=disable to the kernel boot parameters/boot line.

I really don't want to have to tell users to edit the boot parameters themselves, and am looking for a way to, in shell script code, add intel_pstate=disable to the boot parameters while maintaining the existing boot parameters.

What I've already tried

  • Use this code (in a sudo bash shell):
cat /etc/default/grub > grub_bkp
echo "intel_pstate=disable" >> grub_bkp
echo gurb_bkp > /etc/default/grub
  • This doesn't work, take the following /etc/default/grub file for example:
GRUB_CMDLINE_LINUX_DEFAULT='panic=-1 init=/my/cool/file.sh'
  • After my script is done with it, it will look like the following, not successfully applying the kernel boot parameter:
GRUB_CMDLINE_LINUX_DEFAULT='panic=-1 init=/my/cool/file.sh'

Thank you so much for your help! :)

  • 2
    A hint: If you replace this string: GRUB_CMDLINE_LINUX_DEFAULT=' with this: GRUB_CMDLINE_LINUX_DEFAULT='intel_pstate=disable it should work as intended. Look into sed. Oct 3, 2022 at 6:11
  • @ArturMeinild, thank you so much for your help! It worked. I didn't know sed was a thing before. Do you want to write this up as an answer so you can get reputation from upvote and accept? Oct 3, 2022 at 6:32
  • 4
    If your software is intended for the public, a word of warning: I'd consider modifying system parameters like this and increasing the power consumption of my system pretty rude. If I found a piece of software that does that on a system I admin, that software would be gone pretty quickly. Also consider that it may possible to make your software work with pstate enabled, so this is potentially the wrong solution altogether.
    – marcelm
    Oct 3, 2022 at 14:29
  • 1
    @marcelm, thank you for your reply! I'm modified my applications install file, so it says 'Intel Pstate detected. Do you consent to removing it as it causes issues? [Y/N]. Also, my app IS a power saving app, and it can't change clock speeds with pstate enabled. I've done tests and my app greatly outweighs the savings of pstate. I'll try to get it to work with pstate tonight. Have a great day! Oct 3, 2022 at 21:37
  • 1
    @Android776 Fair enough; I agree it's a good idea to inform the user and/or ask permission. Do you have an uninstall procedure? If so, that should probable revert this change. Also, consider including a comment in /etc/default/grub that explains the purpose of disabling pstate so anyone editing that file understands why that parameter is there and what the consequences of removing it are.
    – marcelm
    Oct 4, 2022 at 5:57

1 Answer 1


Use sed to inject a string after the search pattern GRUB_CMDLINE_LINUX_DEFAULT=':

sed -i "s/GRUB_CMDLINE_LINUX_DEFAULT='/&intel_pstate=disable /" /etc/default/grub

After that, also make sure the script updates the GRUB configuration:


The entire script should run as root, since root is required for the above commands.

  • 2
    Also, don't forget update-grub on the following line.
    – mchid
    Oct 3, 2022 at 11:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .