Search My Techie Guy

Wednesday, January 19, 2011

Quick Check – Unix Commands (My Techie Guy's Unix Cheat sheet)


Check the software/kernel version of your unix/linux OS.
# uname -a
Creating a system user with username “user1”
# useradd -d /export/home/user1 -m user1
# passwd user1
Know which applications/drivers are supported (64-bit or 32-bit) by the UNIX kernel
# isainfo –kv
List all configurable hardware resources physically present in the UNIX machine.
# cfgadm -al

List all services and check their state (online or disabled) on Solaris 10, e.g. check if the ftp service is online.
#svcs -a| grep ftp
Enable, disable, and Restart services on Solaris 10, e.g. restart the ftp service
#svcadm restart svc:/network/ftp:default

How to fix the “mkdir: I/O error
#This usually happens when the server recovers from a serious power failure. Suddenly you can’t create a dir on the partition!L!
Example: mkdir: "/var/opt/run": I/O error
#cat /etc/vfstab to get info some info on the mount point.
#Identify the “mount point” and “device to fsck” for this directory ("/var/opt/run")
#umount –f /var/opt/ where “/var/opt/” is the mount point
#fsck /var/opt/ or you can also run the “fsck” on the “device to fsck” which is the raw disk, the latter option is recommended. E.g. fsck /dev/vx/rdsk/vol01 where “/dev/vx/rdsk/vol01” is the “device to fsck”.
#mount /var/opt/ to re-mount the partition.
#And hope it works – Have FunJ.

Find a file in the current directory that is less than one day old (< 24hrs).
find ./ -type f -mtime 0 -exec ls -ltr {} \;
Find a file in the current directory that is greater than 1024bytes (1K) in size.
find ./ -type f -size +1024 -exec ls -lh {} \;

How to fix "Host key verification failed"?

#Have you tried "ssh" from “Server1” to a remote “Server2” and you get this error message?!L!:

#ssh user1@10.10.5.5
Connecting to 10.10.5.5 ..........
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that the RSA host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
03:60:9d:d4:30:d1:54:79:78:9b:4a:e3:9e:1c:21:2e.
Please contact your system administrator.
Add correct host key in /.ssh/known_hosts to get rid of this message.
Offending key in /.ssh/known_hosts:25RSA host key for 10.10.5.5 has changed and you have requested strict checking.
Host key verification failed.

Solution: 
#This simply means that "Server2" has changed identity and is sending a key different from what “Server1” has in its "known_hosts" file. This usually happens when “Server2” has undergone a software upgrade or someone changed the RSA key.

#On “Server1”; look for the "known_hosts" file, usually under: /.ssh/
#vi /.ssh/known_hosts
#look for the line with “Server2” IP address, you can also tell the line from the warning message:
"Offending key in /.ssh/known_hosts:25" meaning it's at line 25
#Delete the entire line/record
#Save  :wq!
#Try again. this time the authentication should not fail but “Server1” will ask you if you want to added the new identity of “Server2”. Just hit "y" for yes and it should connect.
Have fun ... J

Note: This cheat sheet will keep growing based on personal daily experiences as a Unix Server Administrator.

No comments: