Ads

Showing posts with label linux. Show all posts
Showing posts with label linux. Show all posts

Recovering root password under Linux with single user mode


It happens sometime that you can’t remember root password. On Linux, recovering root password can be done by booting Linux under a specific mode: single user mode.
 
This tutorial will show how to boot Linux in single user mode when using GRUB
During normal usage, a Linux OS runs under runlevels between 2 and 5 which corresponds to various multi-user modes. Booting Linux under runlevel 1 will allow one to enter into a specific mode, single user mode. Under such a level, you directly get a root prompt. From there, changing root password is a piece of cake.

 
Some Linux distribution, such as Ubuntu for instance, offer a specific boot menu entry where it is stated “Recovery Mode” or “Single-User Mode“. If this is your case, selecting this menu entry will boot your machine into single user mode, you can carry on with the next part. If not, you might want to read this part.

 
Using GRUB, you can manually edit the proposed menu entry at boot time. To do so, when GRUB is presenting the menu list (you might need to press ESC first), follow those instructions:

 
- use the arrows to select the boot entry you want to modify.
- press e to edit the entry
- use the arrows to go to kernel line
- press e to edit this entry
- at the end of the line add the word: single
- press ESC to go back to the parent menu
- press b to boot this kernel

 
The kernel should be booting as usual (except for the graphical splash screen you might be used to), and you will finally get a root prompt (sh#).
Here we are, we have gained root access to the filesystem, let’s finally change the password.

 
As root, changing password does not ask for your old password, therefore running the command:
# passwd

 
will prompt you for your new password and will ask you to confirm it to make sure there is no typo.

 
That’s it, you can now reboot your box and gain root access again.


Source

To find the kernel version and memory details of LINUX / SOLARIS Operating System


In SOLARIS, uname -r will give you the solaris release level.
some other useful options with uname are


uname -s [Operating system]
SunOS


uname -r [Release version]
5.8

For example if output is:
2.6.22-14-generic

then it denotes:
* 2 : Kernel version
* 6 : The major revision of the kernel
* 22 : The minor revision of the kernel
* 14 : Immediate fixing / bug fixing for critical error
* generic : Distribution specific sting. For example, Redhat appends string such as EL5 to indicate RHEL 5 kernel.


uname -v
Generic_117350-27[OS version]


uname -a
SunOS hostname 5.8 Generic_117350-27 sun4u sparc
The last two words describes h/w name and processor respctl[equivalent to -m and -p),


$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 5 (Tikanga)
this command return the Centos version


To find the Memory details:

dmesg | grep ^Memory:

Output: Memory: 1734144k/1792092k available (2512k kernel code, 49156k reserved, 1396k data, 184k init)

The second value is the physical RAM size. It'll also tell you what other junk is subtracted from that to give you what you get with "free"..

Source