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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • 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. bosh Command Examples (Command-line tool to deploy and manage the bosh director)
  2. apache2ctl Command Examples in Linux
  3. What are makefiles in Linux
  4. iftop: command not found
  5. nordvpn Command Examples in Linux
  6. gvpack Command Examples
  7. dumpe2fs Command Examples in Linux
  8. fluxctl: Command-line tool for Flux v1
  9. How to monitor your CPU on debian or ubuntu systems
  10. gh repo: Work with GitHub repositories on the command-line

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright