• 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. How to Switch Password Algorithm on CentOS/RHEL
  2. How to Restart Network Services in CentOS/RHEL 8
  3. Linux Interview Questions – Basic File and Directory Permissions
  4. CentOS / RHEL : DNS servers in /etc/resolv.conf change after a reboot/network service restart. How to make them permanent
  5. ifrename: command not found
  6. How To Configure NIS (Network Information System) Master and Slave Servers in CentOS/RHEL
  7. How to use “btrfs scrub” command to manage scrubbing on Btrfs file systems
  8. How to use tar command under Linux
  9. How to Disable “alt+ctrl+Del” Key Combination causing reboot in CentOS/RHEL 4,5
  10. How to Connect Remote Host Using the ssh Command

You May Also Like

Primary Sidebar

Recent Posts

  • What are /dev/zero and /dev/null files in Linux
  • grpck command – Remove corrupt or duplicate entries in the /etc/group and /etc/gshadow files.
  • xxd command – Expressed in hexadecimal form
  • sesearch: command not found

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright