Thursday, November 25, 2010

Server is Baremetal or VMWare?

Usually you can type one of the following commands to see if the server you are in is VMWare VM.

[root@VM001 ~]# /sbin/lspci | grep -i vmware
00:0f.0 VGA compatible controller: VMware SVGA II Adapter
[root@qypprdestws03 ~]# grep -i vmware /proc/scsi/scsi
Vendor: VMware Model: Virtual disk Rev: 1.0
Vendor: VMware Model: Virtual disk Rev: 1.0
[root@VM001 ~]# dmidecode | grep -A4 "System Information"
System Information
Manufacturer: VMware, Inc.
Product Name: VMware Virtual Platform
Version: None
Serial Number: VMware-50 00 6e c3 df 0c 97 f1-3e 99 9d 8b 66 a0 8e 24
[root@VM001 ~]#

Thanks/-

Thursday, October 28, 2010

Forgot to use sudo?

Has it happened to you before that - you run a command and forgot to 'sudo' - and hence the commnd fails and now you need to re-run the command all over again? Well in that case this is how you can save some time.

[debu@DebaTestBox ~]$ sudo !!

Forgot 'sudo' before editing a file:

Believe me this is the most frustrating one, and it happens to me a lot to me. You edited quite a few in the file and when try to save&xit( :wq!) you see an error as below

E212: Can't open file for writing
Press ENTER or type command to continue

Well, the below is a savior un this kind of scenario

:w !sudo tee %

this will ask your password the there in, and you are done. All your edits are now recorded by Vim editor.

Cheers!!!

Hope it helps!

DK




Monday, October 25, 2010

ssh client for BlackBerry!

I have been using BlackBerry for quite sometime now - and recently someone asked whether I can have any ssh client there.

Yes! We can. I use MidpSSH, which is a ssh client for MIDP 1.0 / 2.0 (J2ME) devices such as Java capable cellphones and other mobile devices released and distributed under GPL.

So far no issues - and its cool. Here is the link to download -

http://www.xk72.com/midpssh/download.php

You will need to convert .jar/.jad to .alx files

Cheers!
DK

Sunday, October 24, 2010

\'el\ dot

$l. (To be read as \'el\dot )

This is a very infamous but handy and quick command which lists all the hidden files and folders in your current directory. Works both with RHEL4 and RHEL5 as well.

[Debu@DebuTestBox ~]# l.
. .bash_history .bash_profile .cshrc .redhat .swp .Trash .bash_logout .bashrc .ssh .viminfo

Now you probably don't have to use both your hands to press keystrokes for this task :P

Cheers!
DK

telnet UDP port

Wondering how to telnet a UDP port? Use this -

[deba@prodWeb100 ~]$ nc -vvzu PrdSQL100.domain.com 1434

Connection to PrdSQL100.domain.com 1434 port [udp/ms-sql-m] succeeded!

Cheers!
DK

Saturday, October 23, 2010

Start a new shell from Vi editor in emergency !!

Have you ever faced a situation where you unfortunately edited a Read-only file and later realized that either you need to start a duplication putty session to make that file chmod +w or come out from vi editor without saving the data.

If you know this probably you can handle this situation better that to very fast in efficiently!

How:

While being on the bash Vim editor itself go to the command mode and type -

:sh

sh will look up the user's default shell (e.g. the Bourne shell or the C shell) and starts a new shell. In that shell change the permission of the file, type exit(ctrl+d), you will be in the same vi session; now save your file.

Enjoy!
DK

Reading passwords in shell script

Today One BE final year student just asked me this one on IM, for his benefit and anyone who might want to have a password wrapper(if at all!!) here it is how to do the same via a shell script,

#!/bin/sh
###This is a simple bash screipt to read password###
######without echoing the same on console#####

actual="deburocks!"
failed=0
while [ $failed -le 3 ]
do
read -s -p "Password: " userpasswd
echo ""
if [ "$userpasswd" == "$actual" ]
then
echo "Password accepted"
read
exit 1
else
echo "Sorry! Wrong password, Try again..!!"
fi
failed=$(( $failed + 1 ))
done

Please remember - 'stty' can also do the trick as below:

stty -echo
read password
stty echo

Enjoy!!

  🔭 First Impression: Exploring Grafana Mimir              ... After Years with Thanos! Not an observability( OE ) purist, but I do appreci...