June 30, 2015

How To Reset Your Forgotten Root Password On CentOS 7 Servers

Sometimes you forget stuff. I do. I forget important passwords for important websites sometimes. Retrieving your forgotten passwords for most websites is easy, all one has to do remember few details that were used when signing up for the service to get a password reset for an account.
The difference is forgetting a password to a system or device with no easy way to reset it while locked out. CentOS 7 is one such system. If you forget the root password to your CentOS 7 machine, it’s almost virtually impossible to reset it while you’re locked out.
This brief tutorial is going to show you a simple trick that you can use to reset your forgotten root password for CentOS 7 servers. This will definitely come in handy for webmasters who are locked out of your CentOS machine and can’t sign on.
This tutorial will only work if you have direct access to the machine or serial terminal access with boot menu options. You can’t reset the root password if you’re remotely connected since you need boot menu access.
To get started, turn on the machine that you’ve forgotten the root password on. For CentOS 7 devices, you’ll be given 5 seconds at the boot menu to select the operating system kernel to boot into.
That 5 seconds is important, because allows for  admins to select different kernels or edit existing kernel parameters before booting.
At the boot menu, press e to edit the existing kernel (Core) as shown below.
Changing root password on centos 7

Next, scroll down to the list until you see the line underlined below (ro ) . What we need to do is change that ro to rw and start into a bash shell. It should look like this rw init=/sysroot/bin/sh.

forgotten root password on centos 7


Change the ro line to rw and add init=/sysroot/bin/sh
rw init=/sysroot/bin/sh
changing root password on centos

After changing that, press Control + X  or Ctrl + X  on your keyboard to start into single user mode using the bash shell specified above. In this mode, we’re going to change the root password.
In the single user mode, run the command as shown below
chroot /sysroot
password change on centos 7

Finally, run the commands below to change the root password.
change password on centos 7

You’ll be prompted to create and confirm a new password.  After creating the password, run the commands below to update SELinux parameters
touch /.autorelabel

Exit and reboot your system. You should be able to sign on and use the system with the new password you created. That’s how you change the root password on CentOS 7.
Enjoy!

Related Posts:

  • Trình soạn thảo nano và vi trong CentOS 7.0 1. Trình soạn thảo “nano”: Là trình soạn thảo rất phổ biến và dễ dàng sử dụng trong linux, nano có thể đọc được mã Unicode và được cài mặc định trên hầu hết các bản phân phối của Linux. Cách dùng nano cực kỳ đơn … Read More
  • Tổng quan về Virtualization trên CentOS 7.0 1. Tổng quan về ảo hóa trên hệ điều hành mã nguồn mở: Ảo hóa hay Virtualization là công nghệ không còn xa lạ với chúng ta, có rất nhiều công cụ có thể hỗ trợ chúng ta tạo ra những máy ảo như Vmware, Hype… Read More
  • Cài đặt và cấu hình NTP Server trên CentOS 7.0 NTP (viết tắt của Network Time Protocol) là một giao thức mạng có nhiệm vụ đồng bộ về thời gian giữa các hệ thống máy tính hay các mạng dữ liệu có độ trễ. Từ trước năm 1985, NTP đã là một trong những giao… Read More
  • NetworkManager trên CentOS 7.0 1, Tổng quan: NetwordManager là 1 công cụ quản lý kết nối rất tiện dụng trên CentOs và Rethat. NetwordManager có thể được dùng để quản lý các kiểu kết nối: Ethernet, VLANs, Bridges, Bonds ,Teams ,  Wi-Fi,  m… Read More
  • Cài đặt và cấu hình FTP Server trên CentOS 7.0 FTP (viết tắt của File Transfer Protocol) là một giao thức mạng tiêu chuẩn thường được sử dụng để truyền file từ một host này tới một host khác thông qua TCP mà điển hình như là mạng Internet. FTP thườ… Read More

0 comments:

Post a Comment