Password recovery & hostname changes in linux
So..it recently happened to me when I while messing with my system, i wrote a script to change root password & set it to expire in every 7 days & simultaneously making changes to hostname by setting it to a random value.. I queried my friend Raghu for inputs regarding it & got some interesting results,which I will be compiling here. This tutorial is intended for Linux newbies & would help them to get familiar with the enviornment. Actually, after 7 days what happened I tried to log in,& it always said "root password expired, please contact your administrator"..seems familiar ? well..here is how you can eradicate this.
( PS: Folks..if you think you are too dumb to do
that, there exists an automated "burn-the-cd-boot-&-forget-solution"
called KONBOOT which can reset Linux passwords if you care.. :D choose your pick )
I actually rebooted the system & once I reached grub,selected the kernel, I pressed "e".I proceeded to 2nd line of configuration & pressed "e" again.
After that, login as root & then proceed to move to /etc/shadow
you can see there is a "1" in last entry which sets the root account to expire. remove it such that it becomes
Once done, save the file & exit by pressing :wq! in vi. After that, boot into graphical mode by typing
Way 1
open console, & type
WAY 2
The second way deals with editing a file known as "network" located in /etc/sysconfig/network, navigate to it
WAY 3
The third way deals with "sysctl" command, which can be used to change the variable kernel.hostname. Start by checking its current value by typing
where MYHOST.TESTSITE.COM is your new hostname. All of this was scripted,tested in FEDORA 13 (2.6.34.6-47.fc13.i686) & written using Scrib Fire
.
I hope it was interesting :)
Like This post ? You can buy me a Beer :)
Posted by XERO. ALL RIGHTS RESERVED.
( PS: Folks..if you think you are too dumb to do
that, there exists an automated "burn-the-cd-boot-&-forget-solution"
called KONBOOT which can reset Linux passwords if you care.. :D choose your pick )
I actually rebooted the system & once I reached grub,selected the kernel, I pressed "e".I proceeded to 2nd line of configuration & pressed "e" again.
kernel /boot/vmlinuz-2.6.34.6-47.fc13.i686 roObviously, I edited the file by pressing "e" again & modifying it by typing "single" for invoking single user mode in Linux.
kernel /boot/vmlinuz-2.6.34.6-47.fc13.i686 ro singlePress "b" key to boot. Afterwards, you are given a prompt, please enter "passwd" command to reset root password.
After that, login as root & then proceed to move to /etc/shadow
[root@zion XERO]# cd /etc& check the entry for root,it should look similar to this
[root@zion etc]# vi shadow
root:$6$McKhE96JGhl$uIfjBcMrrrL2x8aJ17mATex8WNXVMvZXrsfqoOL.
CinR9W2C8VXVyt4W2yt4eAJ0tgNPU2Kftr1f/lcvDG.:14859:0:99999:7::1:
you can see there is a "1" in last entry which sets the root account to expire. remove it such that it becomes
root:$6$McKhE96JGhl$uIfjBcMrrrL2x8aJ17mATex8WNXVMvZXrsfqoOL.
CinR9W2C8VXVyt4W2yt4eAJ0tgNPU2Kftr1f/lcvDG.:14859:0:99999:7:::
Once done, save the file & exit by pressing :wq! in vi. After that, boot into graphical mode by typing
[root@zion XERO]# init 5login with your password."root" problem solved :) After wards..i found out that my hostname was changed..so, here are three easy ways to change your hostname on your will.
Way 1
open console, & type
[root@zion XERO]# hostnamenow you can reset hostname (for the given session) by typing -
NETWORKING=yes
HOSTNAME=hosty.test.com
[root@zion XERO]# hostname myhostname.mysite.comwhere myhostname.mysite.com is your new hostname.
WAY 2
The second way deals with editing a file known as "network" located in /etc/sysconfig/network, navigate to it
[root@zion XERO]# cd /etc/sysconfig/check the value of hostname in it
[root@zion sysconfig]# cat networktime to change it, go to vi & edit it.
NETWORKING=yes
HOSTNAME=hosty.test.com
[root@zion sysconfig]# vi networksaved the file..reboot & its done :)
NETWORKING=yes
HOSTNAME=myhost.testsite.com
~
~
~
:wq!
WAY 3
The third way deals with "sysctl" command, which can be used to change the variable kernel.hostname. Start by checking its current value by typing
[root@station3 sysconfig]# sysctl kernel.hostnameand to change it, enter
kernel.hostname = hosty.test.com
[root@station3 sysconfig]# sysctl kernel.hostname=MYHOST.TESTSITE.COM
where MYHOST.TESTSITE.COM is your new hostname. All of this was scripted,tested in FEDORA 13 (2.6.34.6-47.fc13.i686) & written using Scrib Fire
.
I hope it was interesting :)
Like This post ? You can buy me a Beer :)
Posted by XERO. ALL RIGHTS RESERVED.