Boot in single user mode on CentOS 7 / RHEL 7

Mattias Geniar, Monday, September 28, 2015 - last modified: Friday, January 1, 2016

This guide will show you how to boot into single user mode on a CentOS 7 server. You'll need single user boot to recover a corrupt file system, reset the root password, ...

First, reboot your server and when you enter the Kernel Selection menu, press e to modify the parameters to boot the kernel.

centos7 single user mode 1

The next screen will show you a confusing screen of kernel parameters. It'll look like this.

centos7 single user mode 2

Scroll down until you find the actual kernel line. It starts with linux16 /vmlinuz-... and will span a couple of lines. You're now looking for the ro keyword in the kernel linux, which would start the OS with a read only (ro) file system.

centos7 single user mode 3

Use your arrow keys to go to the ro line and replace it with rw init=/sysroot/bin/bash. The result should look like this. If that's the case, press ctrl+x to boot the kernel with those options.

centos7 single user mode 4

If everything went fine, you're now in a limited shell with access to the entire filesystem. To make things easier, you can chroot the filesystem so you can access all your known files/directories with the same paths.

centos7 single user mode 5

After you typed chroot /sysroot/, you'll find your familiar files in /etc, /usr,/var, ...

If you're done working in single user mode, reboot again by pressing ctrl+alt+del.

Update: as a reader pointed out, you may have to remount the filesystem from readonly to read-write, too.

mount -o remount,rw /

After that, you should be able to make changes to files on the disk that persist on reboot.

Hi! My name is Mattias Geniar. I'm a Support Manager at Nucleus Hosting in Belgium, a general web geek & public speaker. Currently working on DNS Spy & Oh Dear!. Follow me on Twitter as @mattiasgeniar.

Share this post

Did you like this post? Will you help me share it on social media? Thanks!


VIncent Van der Kussen Wednesday, September 30, 2015 at 22:35 - Reply

afaik, this only works on physical machines. When single booting vm’s you should replace init=/sysroot/bin/bash with rd.break . You also might want to load the SELinux policy.

My 2 cents

    Mattias Geniar Thursday, October 1, 2015 at 04:28 - Reply

    I tested this in VMware/Virtualbox and it still seems to work (at least: it did in my tests).

    As for SELinux: you are indeed right, that should/could be added. Including a rm -f /.autorelabel to avoid having to relabel everything on next boot.

Dennis Thursday, December 31, 2015 at 18:53 - Reply

After booting in single user I also had to run this command so I could make /etc/sudoers writeable:

mount -o remount,rw /
chmod u+w /etc/sudoers

charles Wednesday, November 2, 2016 at 22:40 - Reply

it works for me in rhel7.2 VM environment,
thanks Mattias.


Robby007 Friday, November 25, 2016 at 17:37 - Reply

Thanks a lot… it helps me

Georg Sauthoff Friday, January 13, 2017 at 10:55 - Reply

You don’t really describe how to boot into single user mode – you describe how to boot with bash as PID=1 – i.e. as init replacement.

Booting into single user mode usually means booting to runlevel 1.

And with CentOS/RHEL this is accomplished via adding ` 1` to the kernel command line.

The system then boots into runlevel 1 where you are able to reset your root pw and stuff like that.

This also automatically takes care of SELinux.

paul Thursday, January 26, 2017 at 16:45 - Reply

Instead of the rw init=/sysroot/bin/bash, one could you append to the end of that line init=/bin/bash. Drops to single user prompt. Then do the remount.

olsonn Wednesday, March 29, 2017 at 20:19 - Reply

You saved my life today. Thanks!

Sushant Wednesday, August 2, 2017 at 07:05 - Reply

Thanks a lot, works perfectly fine

Jimmy Lim Wednesday, September 13, 2017 at 05:40 - Reply

Hi All, I have a problem related to this issue. My system was setup in Oracle Virtual Machine VM (CentOS 7). The system will direct boot up OS without showing the GRUB screen. I have tried to interrupt the booting sequence with key strokes at the begnning, “e”, function keys and even “Shift” holding suggested by Ubuntu. Yet the booting continues.

How can I invoke the GRUB menu? Will there be possibility the GRUB has been removed or disabled?

Tom T Wednesday, March 7, 2018 at 00:49 - Reply

This was super-helpful! We had a sysadmin leave w/o giving us root creds to a number of CentOS7 VMs :(

Leave a Reply

Your email address will not be published. Required fields are marked *

Inbound links