0

I'm making script for Post OS install which will be consisting of setting env for Apps and DB and also will include hardening. Doing this manually is not practical which takes hours when a Bash script can do in seconds.

Now for Hardening part I have to set Grub password.

using sed I use this command

sed -i '/timeout/ a password --md5 "$gpassword"' /boot/grub/grub.conf

also tried

sed -i '/timeout/ a password --md5 `grub_crypt' /boot/grub/grub.conf

But problem is this it just write

password --md5 "$gpassword"

in /boot/grub/grub.conf

Is there a way to overcome this and even a better way

1 Answer 1

4

Variables are not expanded within '...', you need to use double-quotes, like this:

sed -i "/timeout/ a password --md5 $gpassword" /boot/grub/grub.conf
2
  • Great it worked, so double quote was the problem Commented Dec 21, 2017 at 8:08
  • @OmiPenguin if this answered your question that perhaps you could upvote + accept it Commented Dec 21, 2017 at 8:20

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.