• 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

CentOS / RHEL : How to disable root login or root access on a system

by admin

Why to disable root login?

– Having the root password defined is not necessary on a linux system. Root password can be disabled but it is not a good practice since the system prompts for the root password absolutely if in case it goes into the maintenance mode. It will not be possible to proceed further in this scenario with sudo access but root password should be provided.
– If an administrator is uncomfortable allowing users to log in as root for these or other reasons, the root password should be kept secret, and access to runlevel one or single user mode should be disallowed through boot loader password protection.
– If still root account need to be disabled on RHEL system for some reasons, the below methods can be followed:

  1. Changing the root shell
  2. Deleting the root password

1. Changing the root shell

For any security reasons to prevent users from logging in directly as root, the system administrator can set the root account’s shell to /sbin/nologin in the /etc/passwd file.

2. Deleting the root password

Deleting the root password also will disable the the access to root account. To do so use the passwd command :

# passwd -d root
Removing password for user root.
passwd: Success
CentOS / RHEL : How to Disable / Enable direct root and non-root user ssh login

Filed Under: Linux

Some more articles you might also be interested in …

  1. Basic Linux File system tutorial – ext2, ext3, ext4, JFS and XFS
  2. pvdisplay Command Examples in Linux
  3. CentOS / RHEL 6 : Install and Configure SNMPv3
  4. How to Uninstall/Remove GNOME from CentOS/RHEL 7
  5. CentOS / RHEL : How to create a Thinly Provisioned Logical Volume
  6. Linux OS Service ‘avahi-daemon’
  7. mocp Command Examples in Linux
  8. How To Create a Local Yum Repository for MySQL Enterprise Packages
  9. Beginner’s Guide to LVM (Logical Volume Management)
  10. CentOS / RHEL : Managing password ageing for users using chage (with practical Examples)

You May Also Like

Primary Sidebar

Recent Posts

  • nixos-rebuild Command Examples in Linux
  • nixos-option: Command Examples in Linux
  • nixos-container : Command Examples in Linux
  • nitrogen Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright