• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

Set Password for Single User Mode on Linux (CentOS/RHEL)

by admin

Setting Password for Single User Mode in Linux adds security to Linux boxes. If someone accesses your server physically & reboots the server and then tries to change the root password from single-user mode. In that case, if the password is set on single-user mode, one has to first enter the root password, then only can reset the root password.

Note – In Debian-like Operating System requires a root password when booting into single user mode or recovery mode. But RHEL & CentOS allows access from the console into single-user mode without a password.

Setting password for Single user mode on CentOS/RHEL 5.x

Edit the file /etc/inittab, add ‘su:S:wait:/sbin/sulogin’ above the line initdefault as shown below:

# vi /etc/inittab
#
# inittab       This file describes how the INIT process should set up
#               the system in a certain run-level.
#
# Author:       Miquel van Smoorenburg, 
#               Modified for RHS Linux by Marc Ewing and Donnie Barnes
#
# Default runlevel. The runlevels used by RHS are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
#
su:S:wait:/sbin/sulogin
id:5:initdefault:

Setting password for single user mode on CentOS/RHEL 6.x

Edit the file /etc/sysconfig/init & replace “SINGLE=/sbin/sushell” with “/sbin/sulogin” as shown below:

# What ttys should gettys be started on?
ACTIVE_CONSOLES=/dev/tty[1-6]
# Set to '/sbin/sulogin' to prompt for password on single-user mode
# Set to '/sbin/sushell' otherwise
SINGLE=/sbin/sulogin

Filed Under: CentOS/RHEL, CentOS/RHEL 5, CentOS/RHEL 6

Some more articles you might also be interested in …

  1. Understanding the /etc/inittab File in Linux
  2. How to Create yum Repository in CentOS/RHEL
  3. How to convert a Volume to Stripe (RAID0) Volume in LVM
  4. How to create an XFS Filesystem
  5. CentOS / RHEL : How to install Open Virtual Machine Tools for Virtual machines Hosted on VMWare
  6. How to Debug systemd boot process in CentOS/RHEL 7 and 8
  7. pam_tally2 command – lock & unlock ssh failed logins in linux
  8. “Authorization not available. Check if polkit service is running or see debug message for more information” – CentOS/RHEL 7 ssh service error
  9. How to Customize Linux Password Expiration and Complexity Requirements
  10. Audit Rule Configuration not Reflected – How to troubleshoot

You May Also Like

Primary Sidebar

Recent Posts

  • qm Command Examples in Linux
  • qm wait Command Examples in Linux
  • qm start Command Examples in Linux
  • qm snapshot Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright