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

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

Root Is Not Able To Login In Red Hat And CentOS

December 3, 2011 by Sharad Chhetri 9 Comments

You may have faced the issue when user root is not able to login in Red Hat and CentOS. Mostly the first thing which come into our mind is might be possible we forgot the password of root and we are not able to login. But apart of this there are other possibilities also which results the failure of root login.

Sharing some of the troubleshooting steps to resolve the user root not login issue.

Forgotten root password

This is mostly happen when we forgot the root password.For resetting the new password we have to boot the Server in Runlevel 1 .

For this “how to” we have already posted in our blog that is Reset Root password in run level 1

Check the no login shell in /etc/passwd file

[root@server ~]# grep root /etc/passwd
root:x:0:0:root:/root:/sbin/nolgin

If you find the above /sbin/nologin in /etc/passwd file for root .Change its login shell into /bin/bash

usermod -s /bin/bash root

for eg.

[root@server ~]# usermod -s /bin/bash root
[root@server ~]# grep root /etc/passwd
root:x:0:0:root:/root:/bin/bash

Check the root account expiration date

chage -l root  (it will show the account information,check the account expiration date).

In case of root account get expired than change it. For troubleshooting purpose we are giving as Never Expired. For more info read man page “man chage “

chage -E never root

[root@server ~]# chage -l root
Last password change                                    : Sep 17, 2011
Password expires                                        : never
Password inactive                                       : never
Account expires                                         : never
Minimum number of days between password change          : 0
Maximum number of days between password change          : 99999
Number of days of warning before password expires       : 7
[root@server ~]#

Check “nologin” directory in /etc

Check nologin directory in /etc . If you find then remove it with help of rm command

ls -ld /etc/nologin && rm -fr /etc/nologin

Check the permission of /etc/securetty

If the permission of file /etc/securetty is other than 644 than it is also one of the problem.
Change /etc/securetty file permission to 644

chmod 644 /etc/securetty

Check the /etc/securetty file’s content

The securetty file must have below given contents and in alphabetical manner. If you find any incorrect information regarding terminals from which root can log in please do remove.

Given below is sample.It may vary as per RHEL/CentOS OS versions.

[root@server~]# cat /etc/securetty
console
vc/1
vc/2
vc/3
vc/4
vc/5
vc/6
vc/7
vc/8
vc/9
vc/10
vc/11
tty1
tty2
tty3
tty4
tty5
tty6
tty7
tty8
tty9
tty10
tty11
[root@server ~]#

Disabled root login in ssh

In case you are trying with ssh to remote host , might be possible in ssh configuration file login to root is not permitted

[root@server ~]# grep Root /etc/ssh/sshd_config
PermitRootLogin no
[root@server ~]#

Then change the value PermitRootLogin yes in /etc/ssh/sshd_config file. And reload or restart the sshd service.

/etc/init.d/sshd reload
 OR 
/etc/init.d/sshd restart

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. lock user login after failed login attempts in Red Hat 6.x and CentOS 6.x
  2. Authenticate root to login in GUI mode in Fedora 10
  3. create and delete user in Red Hat and CentOS
  4. Setup Master Slave Chroot BIND DNS in CentOS 6 or Red Hat 6
  5. How to create multiple mysql instance in CentOS 6.4 and Red Hat 6.4
  6. Install MySQL Server 5.6 in CentOS 6.x and Red Hat 6.x Linux
  7. How to add/install Ubuntu fonts in CentOS/Red Hat Linux
  8. Set GRUB password after installation of CentOS/Red Hat
  9. Recover Linux Grub Password in linux rescue mode CentOS/Red Hat
  10. Password prompt in single user mode is not secure : CentOS/Red Hat

Filed Under: Linux Tagged With: root login

Reader Interactions

Comments

  1. Pradeeba M says

    January 24, 2022 at 10:04 am

    Hi Sharad,

    My Server is Centos 6.8 .I am unable to login directly via root but able to do su – .The root password works.But when we login directly via root user we are getting access denied.Could you please help?

    Reply
  2. Rahul says

    April 28, 2018 at 7:01 am

    I had used killall -u root command and unfortunately killed all the processes including essential ones like log daemon, ssh etc. Unable to log in now. What do I do?

    Reply
    • Sharad Chhetri says

      April 28, 2018 at 5:19 pm

      Hi Rahul,

      Restart the server.

      Regards
      Sharad

      Reply
  3. navneet says

    March 25, 2015 at 12:25 pm

    sir
    i have tried all steps but it won’t let me login inside root whereas i can use my other normal user account but it also don’t show switch user and shut down options plz do reply if you know what is the problem?

    Reply
    • sharad chhetri says

      March 25, 2015 at 5:17 pm

      Hello Navneet,

      May I know what is Operating system and its version.
      The user should be able to login via sudo su - (If the user is allowed in sudoers and have ALL ) , then only you can able to troubleshoot.

      I would like to see the screenshot of error as it seems the information and way you are trying is not clear to me.

      You can send screenshot at admin@sharadchhetri.com

      Regards
      Sharad

      Reply
  4. mayur says

    January 31, 2015 at 9:37 am

    8] IF you have done with above mentioned commands with their result but still you have same issue OR above steps are not working for the resolving root loging issue then
    please try below step.
    just check the .bashrc file i.e. /etc/skel/.bashrc & copy it as cp /etc/skel/.bashrc /root/.bashrc.

    Reply
    • Mauricio says

      July 20, 2017 at 9:06 pm

      This what worked for me, Thanks!!!!

      just check the .bashrc file i.e. /etc/skel/.bashrc & copy it as cp /etc/skel/.bashrc /root/.bashrc.

      Reply
    • Raul Diaz says

      September 1, 2017 at 8:38 pm

      This also worked for me, Thanks, i´m using Centos 6.9 minimal

      Reply
      • Tom says

        September 29, 2017 at 6:38 pm

        How do I do this?

        Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Linux Command

What is Linux Internal And External Command

Linux Basic Commands With Examples For Every Beginner

tr command to convert lines to space , tab and vertical tab

smbpasswd command not found on CentOS 7 and RHEL 7

Solution : semanage command not found

Unix / Linux : How to print duplicate lines from file

More Posts from this Category

You Might Like These Articles!

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

libfuse

dlopen(): error loading libfuse.so.2 – Got Error On Ubuntu

Failed to open/create the internal network

VirtualBox Error: Failed to open/create the internal network

Always Useful Tips And Tricks

GNU Screen

Print double hyphen sign simultaneously in post of Octopress

rsync all files,hidden files,symlinks,hardlinks to remotes Linux Server

Yum Error database disk image is malformed

How to protect from port scanning and smurf attack in Linux Server by iptables

fatal error: error writing to /tmp/ccwAjc9Z.s: No space left on device

find command to search keyword in files recursively in linux

Explore 90+ Article On "Linux Tips And Tricks"

Copyright © 2023 ·
The material in this site cannot be republished either online or offline, without our permission.
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy