Friday, July 8, 2011

Listing the zombie processes in linux

# ps aux |perl -ne '{print if ((split(/\s+/))[7] =~ /Z/)}'
abcuser 6005 0.0 0.0 0 0 pts/6 ZN Jun07 0:00 [gcc]
abcuser 7565 0.0 0.0 0 0 pts/6 ZN Jun07 0:00 [csh]
abcuser 7728 0.0 0.0 0 0 pts/222 ZN Jun01 0:00 [gcc]
root 9902 0.0 0.0 0 0 ? Z Apr09 0:00 [sudo]
user1 13420 0.0 0.0 0 0 pts/202 Z+ Jul06 0:00 [grep]
15800 16275 0.0 0.0 0 0 pts/133 ZN+ 12:45 0:00 [csh]
15800 16315 0.0 0.0 0 0 pts/43 ZN+ 12:46 0:00 [csh]
abcuser 19479 0.0 0.0 0 0 pts/6 ZN Jun07 0:00 [gcc]
abcuser 20173 0.0 0.0 0 0 pts/177 Z May24 0:00 [mgdiff]
user6 20808 0.0 0.0 0 0 ? Z May22 0:00 [sh]
abcuser 21001 0.0 0.0 0 0 pts/6 ZN Jun07 0:00 [gcc]
abcuser 21639 0.0 0.0 0 0 pts/222 ZN Jun01 0:00 [csh]

Friday, June 3, 2011

Adding shortcut in vim to compile perl script

Enter the below line in .vimrc file
map <f5> :w<cr>:!perl %<cr>

Tuesday, December 7, 2010

netstat quick reference

Display all LISTENING tcp ports
# Netstat -ntlp

To swtich the name resolution off use
# netstat -tlp

Display all LISTENING udp ports
# netstat -ulp

To see established tcp connections
# netstat -tp

To find out who has connected through ssh
# netstat -ntp|grep :22
or
# netstat -tp|grep :ssh

Displaying the routing table
netstat -r
or
netstat -rn

Adding IPv6 in linux (RHEL)

Open /etc/sysconfig/network file, enter:
# vi /etc/sysconfig/network

Append following line:
NETWORKING_IPV6=yes

Open /etc/sysconfig/network-scripts/ifcfg-eth0 (1st network config file)
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Append following config directives for IPv6:
IPV6INIT=yes
IPV6ADDR=<IPv6-IP-Address>
IPV6_DEFAULTGW=
<IPv6-IP-Gateway-Address>


Here is a sample file with mix of IPv4 and IPv6 assigned to eth0:
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
HWADDR=00:30:48:33:bc:33
IPADDR=202.54.1.5
GATEWAY=202.54.1.3
NETMASK=255.255.255.248
IPV6INIT=yes
IPV6ADDR=2607:f0d0:1002:0011:0000:0000:0000:0002
IPV6_DEFAULTGW=2607:f0d0:1002:0011:0000:0000:0000:0001


Where,
• NETWORKING_IPV6=yes|no - Enable or disable global IPv6 initialization.
• IPV6INIT=yes - Enable or disable IPv6 configuration for all interfaces.
• IPV6ADDR=2607:f0d0:1002:0011:0000:0000:0000:0002 - Specify a primary static IPv6 address here.
• IPV6_DEFAULTGW=2607:f0d0:1002:0011:0000:0000:0000:0001 - Add a default route through specified gateway.


Save and close the file. Restart networking:
# service network restart

Monday, December 6, 2010

useful rpm commands and examples

#rpm -qa
Dumps all installed packages

#rpm -qi httpd
Dumps information about httpd package

#rpm -qf /usr/bin/httpd
Dumps package membership info for file httpd

#rpm -qpi <url>
Shows package info prior to installation

#rpm -Va
Verifies all packages on the system ,returning info only if there are any discrepencies from the original installation

Verfy httpd package for any discrepencies
#rpm -Vf /usr/bin/httpd
SM5 .... T /usr/bin/httpd
Abbreviations  (SM5)
(file size), M (mode or permissions), 5 (MD5), T (mod time)


#rpm -Vp <url>
Verify the remote package in the internet

Installation


rpm -ivh  <rpm filename>

  • Does not override previous package
  • use this method to install a new version of the kernel
Upgrade (installs or overrides existing package)
#rpm -Uvh  <package name>

Freshen (updates an existing package)
Note: Will not install the package ,if it doesn't exist locally
#rpm -Fvh *.rpm  - Freshens the current version of a package


Package Removal
#rpm -evh *.rpm - removes a package
Note :  Removal process considers dependendies  and will complain if the removal will break one or more packages.To get around this,use 
#rpm -ev --nodeps *.rpm