Friday, June 23, 2006

recover root password

previous post i mentioned about only hp-ux will ask old root password if you want to change the root password. in case you lost the root password, here is a list of a good compilation on how to recover the root password on various flavor of unixes:

Solaris
how do I log into this machine - with a twist... (http://www.unix.com/showthread.php?s=&threadid=1927 )
Lost password on a SPARCstation Voyager (http://www.unix.com/showthread.php?s=&threadid=13702 )
How do I restore the etc/shadow file (http://www.unix.com/showthread.php?s=&threadid=3895 )
Root Password Lost !!! (http://www.unix.com/showthread.php?s=&threadid=9488 )
root locked out (http://www.unix.com/showthread.php?s=&threadid=2492)
sc password (http://www.unix.com/showthread.php?t=22079)

HP-UX
root pwd (http://www.unix.com/showthread.php?s=&threadid=13882)
lost root password using (SAM) trusted security (http://www.unix.com/showthread.php?s=&threadid=2084 )
I lost my password root (http://www.unix.com/showthread.php?s=&threadid=12466 )
passwd file corrupted (http://www.unix.com/showthread.php?t=17175)
Boot interaction ( http://www.unix.com/showthread.php?t=22534 )
Re-enabling a locked root account on Trusted HP-UX (http://www.unix.com/showthread.php?t=25319 )

Linux
root and all but 2 users locked out (http://www.unix.com/showthread.php?s=&threadid=12419 )
root password (http://www.unix.com/showthread.php?s=&threadid=5224)
how to retrieve root paswd ( http://www.unix.com/showthread.php?t=1844)
Help! passwd file corrupted (http://www.unix.com/showthread.php?t=18908)

AIX
root account has been locked (http://www.unix.com/showthread.php?s=&threadid=13658 )
Boot in Single-Mode (http://www.unix.com/showthread.php?t=18760)

Tru64
How to Enable locked root account (http://www.unix.com/showthread.php?s=&threadid=8360 )

SCO
Fortgot root password SCO 5.0. (http://www.unix.com/showthread.php?t=20345)

Ultrix
I neede help!!! (http://www.unix.com/showthread.php?s=&threadid=3208)

NCR Unix
single user mode - user accounts passwords (http://www.unix.com/showthread.php?t=17435)

Windows/XP
Beginners Guides: Forgotten Passwords & Recovery Methods (http://www.unix.com/showthread.php?s=&threadid=16216 )

source: http://www.unix.com/showthread.php?t=14327

ooops, they got for windows as well :)
i think on linux is the easiest one, so make sure you don't lost it :)
or maybe it time to use unix password manager

Tuesday, June 20, 2006

hp-ux change password

just now i tried to change one user password on hp-ux, but it prompt this instead:
# passwd user
Enter your user number here:

what the hell is this? never seen this before. i tried entered a few number but failed :(

but google helped me out :)
actually the system is in trusted mode. a user has been given admnum
check it with /usr/lbin/getprpw -m admnum user
# /usr/lbin/getprpw -m admnum user
admnum=430

provide the number while changing the password
# passwd user
Enter your user number here: 430
Last successful password change for user: NEVER
Last unsuccessful password change for user: Mon Jun 19 00:40:18 2006

New password:
Re-enter new password:

password changed succesfully!

Sunday, June 18, 2006

search engine for developers

this new search engine is dedicated to developers to search for a source code and
technical information.


cool eh, check it out http://www.krugle.com/

Wednesday, June 14, 2006

change root password

i just notice only hp-ux will ask old password if you want to change the root password
$ uname -a
HP-UX hostname B.11.00 U 9000/800 146901507 unlimited-user license
$ passwd
Changing password for root
Old password:

very good security practise i must say.
the rest, linux, solaris & aix, you can simply change the root password to new one without asking the old password.
# uname -a
Linux hostname 2.4.21-32.0.1.nfswan2 #1 SMP Thu Aug 4 11:02:01 CEST 2005 x86_64 x86_64 x86_64 GNU/Linux
# passwd
Changing password for user root.
Enter new UNIX password:

# uname -a
SunOS hostname 5.8 Generic_108528-13 sun4u sparc SUNW,Ultra-2
# passwd
passwd: Changing password for root
New password:

# uname -a
AIX hostname 1 5 0045C2CA4C00
# passwd
Changing password for "root"
root's New password:

Tuesday, June 13, 2006

unix/linux load average

do you know what it mean by load average when you execute these commands:
$ uptime
8:00pm up 238 day(s), 6:06, 39 users, load average: 0.60, 0.27, 0.26

$ w
8:01pm up 238 day(s), 6:07, 39 users, load average: 0.61, 0.30, 0.27

$ top
20:03:19 up 11 days, 5:23, 37 users, load average: 0.24, 0.14, 0.08

$ cat /proc/loadavg
0.12 0.09 0.09 1/253 532

from the man page, really i also not sure since it only says:
DESCRIPTION
The uptime command prints the current time, the length of
time the system has been up, and the average number of jobs
in the run queue over the last 1, 5 and 15 minutes. It is,
essentially, the first line of a w(1) command.

but i've found these articles that nicely explained about this. read it here:
http://www.lifeaftercoffee.com/2006/03/13/unix-load-averages-explained/
http://nosheep.net/story/defining-unix-load-average/
http://www.teamquest.com/resources/gunther/display/5/index.htm

Saturday, June 10, 2006

vi / vim graphical cheat sheet

In an earlier entry, i mentioned about top 10 tips using vi, since it hard to remember it all, i used to have this vi graphical cheat sheet print out on my cubicle for quick reference.


today, while browsing the internet i found another useful & colorful vi/vim graphical cheat sheet. this is a single page describing the full vi/vim input model, the function of all keys, and all major features. you can see it as a compressed vi/vim manual. cool eh :)

source: http://www.viemu.com/vi-vim-cheat-sheet.gif

Friday, June 09, 2006

upgrade ssh server remotely

i've been looking for the most efficient way to upgrade ssh server remotely. this task is quite risky since if the upgrade not going as expected you'll lost your access to the box, unless you have console server connected to it, otherwise you'll need to ask somebody on site to log in locally & start the ssh daemon.

so far i've found several ways to do it:

1. install normal way
i found this useful article on how to upgrade ssh server remotely here
quite straight forward. just that you need to kill the ssh daemon manually & be careful not to kill your current session.

2. using at command
you can set specific time using at command to start the ssh daemon after you've installed it.
or something like:
# /etc/init.d/sshd stop; make install; /etc/init.d/sshd start
but i must say that this is quite risky since you are not sure whether the daemon can start up without any problem after the new installation.
Read more...

3. use different port
some say you better use other port for the new ssh installation. if you can connect to the new ssh server using those port then you can revert it back to the normal port which is 22. low risk but extra steps.

4. enable the backdoor
enable the other remote access which is telnet. i think this is the most safest way to do it even though it is security risk to enable telnet but at least you can still access your box if the ssh kaput!

but how about you need to upgrade a ton of servers? which way you should go?
for me i'll go for no 4. write a script to do:
1) enable telnet & make sure you can access using telnet
2) install/upgrade ssh server & test the installation
with 1 condition, all your servers must have the same configuration. otherwise things gonna mess up pretty bad! good luck :)
or maybe i'll come up with the script later...

Saturday, June 03, 2006

script stdout | shell

when writing a shell script, it is important to make sure it does the correct things, especially when it come to execute the specific commands like rm etcetera. it is advisable to print out to stdout what the commands in the scripts do to make sure no typo/error made.
eg: script.sh
#! /bin/ksh
for file in *.log
do
echo rm $file
done

so when you run the script:
$ ./script.sh
rm 1.log
rm 2.log
rm 3.log

it will not execute the rm command since we only use echo. in order to execute it, no need to delete the echo but simpy pipe ( | ) it to the shell:
$ ./script.sh | sh

will delete those 3 log files.