Solaris: what process is listening on certain port?

I found this small code which works with charm:

#!/bin/ksh

line='---------------------------------------------'
pids=$(/usr/bin/ps -ef | sed 1d | awk '{print $2}')

if [ $# -eq 0 ]; then
   read ans?"Enter port you would like to know pid for: "
else
   ans=$1
fi

for f in $pids
do
   /usr/proc/bin/pfiles $f 2>/dev/null | /usr/xpg4/bin/grep -q "port: $ans"
   if [ $? -eq 0 ]; then
      echo $line
      echo "Port: $ans is being used by PID:\c"
      /usr/bin/ps -ef -o pid -o args | egrep -v "grep|pfiles" | grep $f
   fi
done
exit 0
Posted in unix | Leave a comment

configure Intel Corporation 82562GT 10/100 Network Connection (rev 03) – Debian lenny

To get your wireless working for Intel Corporation 82562GT 10/100 Network Connection (rev 03)

Add the following repository in /etc/apt/sources.list

deb http://ftp.de.debian.org/debian lenny main non-free

then do
apt-get update
apt-get install firmware-iwlwifi
/etc/init.d/network-manager restart

You should get the list of available wireless networks.

More info

Anuj

Posted in Linux | Leave a comment

error while loading shared libraries: libstdc++.so.5 – ubuntu

As libstdc++.so.5 package in the karmic repository, install with the jaunty.

Add following in /etc/apt/sources.list

deb http://cz.archive.ubuntu.com/ubuntu jaunty main universe

Now do:

  • apt-get update
  • apt-get install libstdc++5

Anuj

Posted in Linux | Leave a comment

debian5.05 (lenny) netinstall using usb drive

  1. Download boot.img.gz
  2. Insert your usb drive, be careful with the following command (I have my usb drive as /dev/sdb).
    zcat boot.img.gz >/dev/sdb
  3. Now mount /dev/sdb
    mount /dev/sdb /mnt
  4. Download Copy Debian netinst iso in /mnt. (Depending on your machine arch)
  5. Now boot from USB. Plug-in the network cable or configure your wifi and perform the installation.

In case you already having a LVM from earlier distribution you may get error of partition already in use while configuring your LVM. In this case get to the console by pressing alt+ctrl+F2 key (F2 or F3) and hit enter. Now give vgchange -aln then get back to your partitioning section and proceed.

A good tutorial is available on the debian site.

http://www.debian.org/releases/lenny/i386/ch04s03

Anuj


Posted in Linux | Leave a comment

route/link/vlan.c:51: error: ‘VLAN_FLAG_REORDER_HDR’ undeclared here (not in a function)

Error while running make of libnl-1.1.

Entering lib
MAKE libnl.so.1.1
CC route/link/vlan.c
route/link/vlan.c:51: error: ‘VLAN_FLAG_REORDER_HDR’ undeclared here (not in a function)
make[2]: *** [route/link/vlan.o] Error 1
make[1]: *** [all] Error 2
make: *** [all] Error 2

Patch is available on link

More details:

http://bugs.gentoo.org/210208

Anuj

Posted in Linux | Leave a comment

configure wireless network – Back Track 4

To configure wireless network on Back Track 4 (PwnSauce)

  1. Identify your wireless extensions, for example you found wlan0
  2. Create a wpa_supplicant.conf file with the following entries:
  3. network={
    ssid=”NetworkName”
    scan_ssid=1
    key_mgmt=WPA-PSK
    psk=”Password”
    }
  4. Then issue command:
    wpa_supplicant -i wlan0  -c wpa_supplicant.conf
  5. on another terminal give:
    ifup wlan0

In case of issue, check the logs ;)

Posted in Linux | Leave a comment

chm file read on rhel5*

Download  & install xchm from:

http://devil.homelinux.org/CentOS5/Xchm/

Posted in Linux | Leave a comment

root DNS Cooperative Research and Development Agreement (CRADA)

Research and Development Agreement (CRADA)

Posted in Misc | Leave a comment

Disable MOTD at the login time

If you login to a unix machine, mostly you have seen some creepy long message scrolling down your screen ehh! coming from /etc/motd.

You remembered all 8-10 long line’s isn’t it ;) follow your company policies.

In case you want to disable, you need to just type:

>~.hushlogin

Next time when you’re going to login, you’ll get simple direct shell, no MOTD.

Posted in unix | Leave a comment

ksh not parsing escape sequence with echo “\n” on RHEL5

If your kshell scripts which you migrated from RHEL4 or earlier are behaving strange, for example a small script:

[root@localhost ~]# cat /tmp/test.ksh
#!/bin/ksh
#demonstration
echo “\n”

it’s going to give a new line, right? But no, with the default kshell installed it’s not the same, as redhat 5+ is not using pdksh(public domain korn shell). When we execute the above small piece of kshell code:

[root@localhost ~]# ksh /tmp/test.ksh
\n
[root@localhost ~]#

Which is not a new line output (as expected).

To make it working, do yum install pdksh ( in case your server is registered with the redhat) else you can download pdksh rpm from centos site and do rpm -ivh pdksh-*.rpm

Now next step would be, either remove ksh rpm or better use alternatives command (you need to be root to use it) . Second one option is more useful, so here we go:

[root@localhost ~]# alternatives –config ksh

There are 2 programs which provide ‘ksh’.

Selection    Command
———————————————–
*+ 1           /bin/ksh93
2           /bin/pdksh

Enter to keep the current selection[+], or type selection number:2

Select option 2 (showing path to pdksh)

Now test your ksh script.

[root@localhost ~]# ksh /tmp/test.ksh

[root@localhost ~]#

It worked, echo “\n” is working as expected !!

That’s it…
Anuj

Posted in Linux | Leave a comment