Protect single user mode with root password

 

 

Question: How to protect single user mode with root password

 

To make your linux machine more secure. Protecting its single user mode with password  is one of the good practice.

Their is file called /etc/inittab in linux which decides the linux box runlevel while system boots. inittab file contains 4 fields and which are given  below.

Fields in /etc/inittab
label: run_level: action :process

To protect your single usermode with root password. Add the below line in file /etc/inittab

su:S:wait:/sbin/sulogin

1. SU  , is just a label
2. S    , enter in to single user mode
3. wait  , starts the process and waits for it to complete before going on to the next inittab entry.

4. /sbin/sulogin , which only allows root user to login

Reboot the machine and go to single user mode it will ask for root password