Password-protecting boot option steps for both Ubuntu and Red Hat

From here on out, the steps are the same for both the CentOS and the Ubuntu virtual machines, except for the following:

  • On your Ubuntu machine, the grub.cfg file is in the /boot/grub/ directory.  On your CentOS machine, it's in the /boot/grub2/ directory.
  • On Ubuntu, the /boot/grub/ and /etc/grub.d/ directories are world-readable. So, you can cd into them as a normal user. 
  • On CentOS, the /boot/grub2/ and /etc/grub.d/ directories are restricted to the root user. So, to cd into them, you'll need to log in to the root user's shell. Alternatively, you can list the contents from your normal user shell with sudo ls -l, and you can edit the files you need to edit with sudo vim /boot/grub2/grub.cfg ...

Get Mastering Linux Security and Hardening now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.