Showing posts with label Linux fundamentals. Show all posts
Showing posts with label Linux fundamentals. Show all posts

Monday, April 12, 2021

LVM Volumes Resize - Increase and decrease example (rootvol)

 


#########################################################################################################################

#

#                                LVM - SHRINKING A VOLUME AND EXT4 FILESYSTEM 

#

#########################################################################################################################



root@system1:~# df -h /scratch

Filesystem                  Size  Used Avail Use% Mounted on

/dev/mapper/vg00-scratchlv   74G   53M   70G   1% /scratch


root@system1:~# umount /scratch


root@system1:~# e2fsck -f  /dev/mapper/vg00-scratchlv

e2fsck 1.44.1 (24-Mar-2018)

Pass 1: Checking inodes, blocks, and sizes

Pass 2: Checking directory structure

Pass 3: Checking directory connectivity

Pass 4: Checking reference counts

Pass 5: Checking group summary information

/dev/mapper/vg00-scratchlv: 12/4898816 files (0.0% non-contiguous), 451906/19589120 blocks

root@system1:~# 


root@system1:~# resize2fs /dev/mapper/vg00-scratchlv 1G

resize2fs 1.44.1 (24-Mar-2018)

Resizing the filesystem on /dev/mapper/vg00-scratchlv to 262144 (4k) blocks.

The filesystem on /dev/mapper/vg00-scratchlv is now 262144 (4k) blocks long.



root@system1:~# lvreduce -L 1G /dev/mapper/vg00-scratchlv

  WARNING: Reducing active logical volume to 1.00 GiB.

  THIS MAY DESTROY YOUR DATA (filesystem etc.)

Do you really want to reduce vg00/scratchlv? [y/n]: y

  Size of logical volume vg00/scratchlv changed from <74.73 GiB (19130 extents) to 1.00 GiB (256 extents).

  Logical volume vg00/scratchlv successfully resized.

root@system1:~# 


root@system1:~# e2fsck -f  /dev/mapper/vg00-scratchlv

e2fsck 1.44.1 (24-Mar-2018)

Pass 1: Checking inodes, blocks, and sizes

Pass 2: Checking directory structure

Pass 3: Checking directory connectivity

Pass 4: Checking reference counts

Pass 5: Checking group summary information

/dev/mapper/vg00-scratchlv: 12/65536 files (0.0% non-contiguous), 140322/262144 blocks


 

root@system1:~# mount /scratch

root@system1:~# df -h /scratch

Filesystem                  Size  Used Avail Use% Mounted on

/dev/mapper/vg00-scratchlv  496M   21M  409M   5% /scratch

 


#########################################################################################################################

#

#                                LVM - EXPANDING A VOLUME AND EXT4 FILESYSTEM 

#

#########################################################################################################################



root@system1:~# df -h /

Filesystem               Size  Used Avail Use% Mounted on

/dev/mapper/vg00-rootlv   19G   18G     0 100% /

 

root@system1:~# blkid /dev/mapper/vg00-rootlv

/dev/mapper/vg00-rootlv: UUID="5f562e25-6fa0-4cea-8058-6506dbc1dfde" TYPE="ext4"


 

root@system1:~# pvs

  PV         VG   Fmt  Attr PSize   PFree  

  /dev/sda6  vg00 lvm2 a--  <99.52g <73.73g


 

root@system1:~# vgs

  VG   #PV #LV #SN Attr   VSize   VFree  

  vg00   1   4   0 wz--n- <99.52g <73.73g


 

root@system1:~# lvs

  LV        VG   Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert

  rootlv    vg00 -wi-ao---- 19.07g                                                    

  scratchlv vg00 -wi-ao----  1.00g                                                    

  swaplv    vg00 -wi-ao---- <1.91g                                                    

  tmplv     vg00 -wi-ao----  3.81g                                                    

root@system1:~# 


root@system1:~# lvextend -l +100%FREE /dev/mapper/vg00-rootlv

  Size of logical volume vg00/rootlv changed from 19.07 GiB (4882 extents) to <92.80 GiB (23756 extents).

  Logical volume vg00/rootlv successfully resized.

 

root@system1:~# df -h /

Filesystem               Size  Used Avail Use% Mounted on

/dev/mapper/vg00-rootlv   19G   18G     0 100% /


root@system1:~# resize2fs /dev/mapper/vg00-rootlv

resize2fs 1.44.1 (24-Mar-2018)

Filesystem at /dev/mapper/vg00-rootlv is mounted on /; on-line resizing required

old_desc_blocks = 3, new_desc_blocks = 12

The filesystem on /dev/mapper/vg00-rootlv is now 24326144 (4k) blocks long.


root@system1:~# df -h /

Filesystem               Size  Used Avail Use% Mounted on

/dev/mapper/vg00-rootlv   92G   18G   70G  21% /

root@system1:~# 


root@system1:~# lvs

  LV        VG   Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert

  rootlv    vg00 -wi-ao---- <92.80g                                                    

  scratchlv vg00 -wi-ao----   1.00g                                                    

  swaplv    vg00 -wi-ao----  <1.91g                                                    

  tmplv     vg00 -wi-ao----   3.81g                                                    




Wednesday, January 8, 2020

AWK with if-else loop example

Bash script with AWK example - in this example, if the line contains one type of keywords, I wanted to add something in the end of same line and if the line contained something else, I wanted to add some other text.
cat /tmp/file1 |  \
 awk '{ 
  if ($0~"RHEL" || $0~"rhel" || $0~"CENT" || $0~"cent") 
            print $0 " --os-family \"Redhat\""
  if ($0~"Ubuntu" || $0~"UBUN" || $0~"ubun")
            print $0 " --os-family \"Debian\""
 };' > /tmp/file2

Wednesday, April 5, 2017

Kickstart troubleshooting

This is to see if a server which need to be kickstarted is able to get initial files from TFTP server (which runs on port 69).
[root@kickstarter pxelinux.cfg]# tcpdump -i eth0 port 69
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
11:30:19.077306 IP srv-9000.ah-esp-encap > kickstarter.domain.com.tftp:  41 RRQ "linux-install/pxelinux.0" octet tsize 0
11:30:19.106252 IP srv-9000.acp-port > kickstarter.domain.com.tftp:  46 RRQ "linux-install/pxelinux.0" octet blksize 1456
11:30:19.183548 IP srv-9000.40769 > kickstarter.domain.com.tftp:  77 RRQ "linux-install/pxelinux.cfg/01-c4-34-6b-b9-16-70" octet tsize 0 blksize 1440
11:30:19.213799 IP srv-9000.40770 > kickstarter.domain.com.tftp:  65 RRQ "linux-install/pxelinux.cfg/0A4461FA" octet tsize 0 blksize 1440
11:30:19.242361 IP srv-9000.40771 > kickstarter.domain.com.tftp:  63 RRQ "linux-install/rhel-as-7u1/vmlinuz" octet tsize 0 blksize 1440
11:30:35.973742 IP srv-9000.40772 > kickstarter.domain.com.tftp:  66 RRQ "linux-install/rhel-as-7u1/initrd.img" octet tsize 0 blksize 1440
^C
6 packets captured
38 packets received by filter
1 packets dropped by kernel

Monday, February 27, 2017

Annoying GUI Pop-up in VNC and how to disable it?

# ls -l /etc/xdg/autostart/gpk-update-icon.desktop
-rw-r--r-- 1 root root 7115 Feb 16 16:04 /etc/xdg/autostart/gpk-update-icon.desktop
Append below line in above mentioned file:
X-GNOME-Autostart-enabled=false

Once done, restart server and the pop-up shown above should be gone.

Monday, June 22, 2015

How to extend X11 forwarding after SUDO?

Most of the time "ssh -X username@servername" works for X11 (display) forwarding via SSH protocol. However, when we need to sudo to any application user, X11 does not work from that point on. Here is a quick fix to that problem.
[/user/johnc] $ ssh -X server1
johnc@server1's password:
Warning: No xauth data; using fake authentication data for X11 forwarding.
Last login: Sat Jun 20 04:58:57 2015 from 10.68.76.230
[johnc@server1 ~]$
[johnc@server1 ~]$ xterm
[johnc@server1 ~]$ xauth list
server1/unix:10  MIT-MAGIC-COOKIE-1  [some output.....]


[johnc@server1 ~]$ sudo -u appuser -H -s
bash-4.1$ xauth add server1/unix:10  MIT-MAGIC-COOKIE-1   [some output.....] 
xauth:  creating new authority file /user/appuser/.Xauthority

bash-4.1$ id
uid=1002(appuser) gid=310(dba) groups=310(dba)

bash-4.1$ xterm
Now XTERM will open with out any problem!

Monday, April 20, 2015

How to check SSL Certificate information from a Linux server?

-bash-3.2# echo | openssl s_client -connect starcat:443 2>/dev/null | openssl x509 -noout -issuer -subject -dates 
issuer= /C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert SHA2 High Assurance Server CA
subject= /C=US/ST=California/L=Santa Clara/O=ABC Company, Inc./CN=*.abc.com
notBefore=Dec  9 00:00:00 2013 GMT
notAfter=Feb 23 12:00:00 2017 GMT


-bash-3.2# echo | openssl s_client -connect unix:443 2>/dev/null | openssl x509 -noout -issuer -subject -dates 
issuer= /C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert SHA2 High Assurance Server CA
subject= /C=US/ST=California/L=Santa Clara/O=ABC Company, Inc./CN=*.abc.com
notBefore=Dec  9 00:00:00 2013 GMT
notAfter=Feb 23 12:00:00 2017 GMT

Thursday, September 5, 2013

How to fix Linux Quota? - "group block limit reached" error.

[userA@groupA1]$ cat TESTFILE > TESTFILE1 
sda8: write failed, group block limit reached.
cat: write error: Disk quota exceeded

 # cat /etc/fstab 
/dev/sda3                 /                       ext3    defaults        1 1
/dev/sda8             /home                   ext3    defaults,usrquota,grpquota     1 2
/dev/sda7              /tmp                    ext3    defaults        1 2
/dev/sda6              /var                    ext3    defaults        1 2
/dev/sda5              /opt                    ext3    defaults        1 2
/dev/sda1             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/sda2         swap                    swap    defaults        0 0


Note: Here is the command to edit quota for group (This has to run as root).

# edquota -g groupA1

[userA@groupA1]$ quota -gl 
Disk quotas for group groupA1 (gid 60000):
     Filesystem  blocks   quota   limit   grace   files   quota   limit   grace
      /dev/sda8  185168* 150000  200000   6days    8393       0       0

Thursday, June 6, 2013

How to scan a new disk in Linux without rebooting?

Here is the quick and dirty way to scan new hard-disk in Linux.
[root@server-01 ~]# fdisk -l
Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104390+  83  Linux
/dev/sda2              14        3263    26105623+  8e  Linux LVM


[root@server-01 ~]# ls -lh /sys/class/scsi_host/host0/scan
--w------- 1 root root 4.0K Jun  6 19:13 /sys/class/scsi_host/host0/scan

[root@server-01 ~]# echo "- - -" > /sys/class/scsi_host/host0/scan 

[root@server-01 ~]# fdisk -l
Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104390+  83  Linux
/dev/sda2              14        3263    26105623+  8e  Linux LVM

Disk /dev/sdb: 107.3 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

[root@server-01 ~]# tail -30 /var/log/messages
Jun  2 04:02:04 server-01 syslogd 1.4.1: restart.
Jun  6 19:13:30 server-01 kernel:   Vendor: VMware    Model: Virtual disk      Rev: 1.0
Jun  6 19:13:30 server-01 kernel:   Type:   Direct-Access                      ANSI SCSI revision: 02
Jun  6 19:13:30 server-01 kernel:  target0:0:1: Beginning Domain Validation
Jun  6 19:13:30 server-01 kernel:  target0:0:1: Domain Validation skipping write tests
Jun  6 19:13:30 server-01 kernel:  target0:0:1: Ending Domain Validation
Jun  6 19:13:30 server-01 kernel:  target0:0:1: FAST-40 WIDE SCSI 80.0 MB/s ST (25 ns, offset 127)
Jun  6 19:13:30 server-01 kernel: SCSI device sdb: 209715200 512-byte hdwr sectors (107374 MB)
Jun  6 19:13:30 server-01 kernel: sdb: Write Protect is off
Jun  6 19:13:30 server-01 kernel: sdb: cache data unavailable
Jun  6 19:13:30 server-01 kernel: sdb: assuming drive cache: write through
Jun  6 19:13:30 server-01 kernel: SCSI device sdb: 209715200 512-byte hdwr sectors (107374 MB)
Jun  6 19:13:30 server-01 kernel: sdb: Write Protect is off
Jun  6 19:13:30 server-01 kernel: sdb: cache data unavailable
Jun  6 19:13:30 server-01 kernel: sdb: assuming drive cache: write through
Jun  6 19:13:30 server-01 kernel:  sdb: unknown partition table
Jun  6 19:13:30 server-01 kernel: sd 0:0:1:0: Attached scsi disk sdb
Jun  6 19:13:30 server-01 kernel: sd 0:0:1:0: Attached scsi generic sg1 type 0

Saturday, March 30, 2013

How to mount NFS volume at Boot time in Linux?

It seems very basic thing - however, coming from Solaris background, it was always a puzzle why Linux was not able to mount my NFS volumes the way it was mounting in Solaris. Basically, the only difference is "_netdev" keyword - which tells Linux that this device should be mounted AFTER network services are UP. To work around this, I even used a custom run-control script at /etc/rc3.d to mount it later. Now that I found "_netdev" keyword - I know that I am never going to use any workarounds for my NFS volumes. :)
[root@snet102 ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Nov 13 14:06:32 2012
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/vg_rl6u3vanilla-lv_root /                       ext4    defaults        1 1
UUID=2309506a-eed6-413e-b234-0587949c3504 /boot                   ext4    defaults        1 2
/dev/mapper/vg_rl6u3vanilla-lv_swap swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
##
client10:/iscsi1/nfsdata  /nfstest2             nfs     _netdev         0 0
##


[root@snet102 ~]# df -hFnfs
Filesystem            Size  Used Avail Use% Mounted on
client10:/iscsi1/nfsdata
                      2.0G   37M  1.9G   2% /nfstest2

How to find RHEL NFS statistics?

Use following command to get NFS-IO-Statistics::
# watch -n 2 'nfsiostat'

Sunday, March 24, 2013

How to setup YUM Group repository?


[root@server12 RHEL6U3]# find . -name *comp*.xml 
./repodata/c27858b7430afeb372d0dd50d8a56fd46b47bc81bb9580c2bb91ab697e40592e-comps-rhel6-Server.xml
./LoadBalancer/repodata/68973170f9d30c707e01b3535aa78ab02aa34cd2b97828d84d86c597dcf8015a-comps-rhel6-LoadBalancer.xml
./ScalableFileSystem/repodata/6c210eb621f2c6eecbd5735b08aac6fd333d49988bc33c3782300c1ee42e664b-comps-rhel6-ScalableFileSystem.xml
./ResilientStorage/repodata/1ba11090cede347f3d945ea51de8aaab5bbeaaddd5bc307904b672b704b4bc5d-comps-rhel6-ResilientStorage.xml
./Server/repodata/c27858b7430afeb372d0dd50d8a56fd46b47bc81bb9580c2bb91ab697e40592e-comps-rhel6-Server.xml
./HighAvailability/repodata/917bc97ad20955bccfacfda8186451465fd740ac264ed8b436666fb5eb9ca3d1-comps-rhel6-HighAvailability.xml
[root@server12 RHEL6U3]# 



[root@server12 RHEL6U3]# createrepo -g ./Server/repodata/c27858b7430afeb372d0dd50d8a56fd46b47bc81bb9580c2bb91ab697e40592e-comps-rhel6-Server.xml  . 
1097/3653 - Packages/openldap-servers-2.4.23-26.el6.x86_64.rpm                  
iso-8859-1 encoding on Ville Skytt�  - 2.8.2-2

3653/3653 - Packages/urlview-0.9-7.el6.x86_64.rpm                               
Saving Primary metadata
Saving file lists metadata
Saving other metadata

[root@server12 RHEL6U3]# find . -newer a 
.
./repodata
./repodata/primary.xml.gz
./repodata/filelists.xml.gz
./repodata/repomd.xml
./repodata/c27858b7430afeb372d0dd50d8a56fd46b47bc81bb9580c2bb91ab697e40592e-comps-rhel6-Server.xml.gz
./repodata/other.xml.gz
./repodata/c27858b7430afeb372d0dd50d8a56fd46b47bc81bb9580c2bb91ab697e40592e-comps-rhel6-Server.xml
[root@server12 RHEL6U3]# 
[root@server12 RHEL6U3]# 

[root@server12 RHEL6U3]# vi /etc/yum.conf 
[root@server12 RHEL6U3]# 

[root@server12 RHEL6U3]# yum grouplist 
Loaded plugins: product-id, subscription-manager
Updating Red Hat repositories.
Setting up Group Process
unixgeek                                                                                                                     | 2.0 kB     00:00 ... 
unixgeek/primary                                                                                                             | 1.7 MB     00:00 ... 
unixgeek/group_gz                                                                                                            | 204 kB     00:00 ... 
Installed Groups:
   Additional Development
   CIFS file server
   Console internet tools
   Directory Client
   Directory Server
   E-mail server
   FTP server
   General Purpose Desktop
   Graphical Administration Tools
   Internet Browser
   Legacy UNIX compatibility
   Legacy X Window System compatibility
   Messaging Client Support
   NFS file server
   Network Infrastructure Server
   Network file system client
   Perl Support
   PostgreSQL Database client
   Remote Desktop Clients
   Web Server
   iSCSI Storage Client
Available Groups:
   Backup Client
   Backup Server
   Base
   Client management tools
   Compatibility libraries
   Debugging Tools
   Desktop
   Desktop Debugging and Performance Tools
   Desktop Platform
   Desktop Platform Development
   Development tools
   Dial-up Networking Support
   Eclipse
   Emacs
   FCoE Storage Client
   Fonts
   Graphics Creation Tools
   Hardware monitoring utilities
   Identity Management Server
   Infiniband Support
   Input Methods
   Java Platform
   KDE Desktop
   Large Systems Performance
   Mainframe Access
   MySQL Database client
   MySQL Database server
   Network Storage Server
   Networking Tools
   PHP Support
   Performance Tools
   PostgreSQL Database server
   Print Server
   Printing client
   Ruby Support
   SNMP Support
   Scientific support
   Security Tools
   Server Platform
   Server Platform Development
   Smart card support
   Somali Support
   Storage Availability Tools
   System Management
   System administration tools
   Systems Management Messaging Server support
   TeX support
   Technical Writing
   TurboGears application framework
   Virtualization
   Virtualization Client
   Virtualization Platform
   Virtualization Tools
   Web Servlet Engine
   Web-Based Enterprise Management
   X Window System
Available Language Groups:
   Afrikaans Support [af]
   Albanian Support [sq]
   Amazigh Support [ber]
   Arabic Support [ar]
   Armenian Support [hy]
   Assamese Support [as]
   Azerbaijani Support [az]
   Basque Support [eu]
   Belarusian Support [be]
   Bengali Support [bn]
   Bhutanese Support [dz]
   Brazilian Portuguese Support [pt_BR]
   Breton Support [br]
   Bulgarian Support [bg]
   Catalan Support [ca]
   Chhattisgarhi Support [hne]
   Chichewa Support [ny]
   Chinese Support [zh]
   Coptic Support [cop]
   Croatian Support [hr]
   Czech Support [cs]
   Danish Support [da]
   Dutch Support [nl]
   English (UK) Support [en_GB]
   Esperanto Support [eo]
   Estonian Support [et]
   Ethiopic Support [am]
   Faroese Support [fo]
   Fijian Support [fj]
   Filipino Support [fil]
   Finnish Support [fi]
   French Support [fr]
   Frisian Support [fy]
   Friulian Support [fur]
   Gaelic Support [gd]
   Galician Support [gl]
   Georgian Support [ka]
   German Support [de]
   Greek Support [el]
   Gujarati Support [gu]
   Hebrew Support [he]
   Hiligaynon Support [hil]
   Hindi Support [hi]
   Hungarian Support [hu]
   Icelandic Support [is]
   Indonesian Support [id]
   Interlingua Support [ia]
   Inuktitut Support [iu]
   Irish Support [ga]
   Italian Support [it]
   Japanese Support [ja]
   Kannada Support [kn]
   Kashmiri Support [ks]
   Kashubian Support [csb]
   Kazakh Support [kk]
   Khmer Support [km]
   Kinyarwanda Support [rw]
   Konkani Support [kok]
   Korean Support [ko]
   Kurdish Support [ku]
   Lao Support [lo]
   Latin Support [la]
   Latvian Support [lv]
   Lithuanian Support [lt]
   Low Saxon Support [nds]
   Luxembourgish Support [lb]
   Macedonian Support [mk]
   Maithili Support [mai]
   Malagasy Support [mg]
   Malay Support [ms]
   Malayalam Support [ml]
   Maltese Support [mt]
   Manx Support [gv]
   Maori Support [mi]
   Marathi Support [mr]
   Mongolian Support [mn]
   Myanmar (Burmese) Support [my]
   Nepali Support [ne]
   Northern Sotho Support [nso]
   Norwegian Support [nb]
   Occitan Support [oc]
   Oriya Support [or]
   Persian Support [fa]
   Polish Support [pl]
   Portuguese Support [pt]
   Punjabi Support [pa]
   Romanian Support [ro]
   Russian Support [ru]
   Sanskrit Support [sa]
   Sardinian Support [sc]
   Serbian Support [sr]
   Sindhi Support [sd]
   Sinhala Support [si]
   Slovak Support [sk]
   Slovenian Support [sl]
   Southern Ndebele Support [nr]
   Southern Sotho Support [st]
   Spanish Support [es]
   Swahili Support [sw]
   Swati Support [ss]
   Swedish Support [sv]
   Tagalog Support [tl]
   Tajik Support [tg]
   Tamil Support [ta]
   Telugu Support [te]
   Tetum Support [tet]
   Thai Support [th]
   Tibetan Support [bo]
   Tsonga Support [ts]
   Tswana Support [tn]
   Turkish Support [tr]
   Turkmen Support [tk]
   Ukrainian Support [uk]
   Upper Sorbian Support [hsb]
   Urdu Support [ur]
   Uzbek Support [uz]
   Venda Support [ve]
   Vietnamese Support [vi]
   Walloon Support [wa]
   Welsh Support [cy]
   Xhosa Support [xh]
   Zulu Support [zu]
Done
[root@server12 RHEL6U3]# 
[root@server12 RHEL6U3]# 
[root@server12 RHEL6U3]# 
[root@server12 RHEL6U3]# yum groupinstall 'Web Server' 
Loaded plugins: product-id, subscription-manager
Updating Red Hat repositories.
unixgeek                                                                                                                                  3653/3653
Setting up Group Process
Resolving Dependencies
--> Running transaction check
---> Package crypto-utils.x86_64 0:2.4.1-24.2.el6 will be installed
--> Processing Dependency: perl(Newt) for package: crypto-utils-2.4.1-24.2.el6.x86_64
---> Package httpd.x86_64 0:2.2.15-9.el6 will be updated
--> Processing Dependency: httpd = 2.2.15-9.el6 for package: httpd-devel-2.2.15-9.el6.x86_64
---> Package httpd.x86_64 0:2.2.15-15.el6_2.1 will be an update
--> Processing Dependency: httpd-tools = 2.2.15-15.el6_2.1 for package: httpd-2.2.15-15.el6_2.1.x86_64
---> Package httpd-manual.noarch 0:2.2.15-9.el6 will be updated
---> Package httpd-manual.noarch 0:2.2.15-15.el6_2.1 will be an update
---> Package mod_perl.x86_64 0:2.0.4-10.el6 will be installed
--> Processing Dependency: perl(ExtUtils::MakeMaker) for package: mod_perl-2.0.4-10.el6.x86_64
--> Processing Dependency: perl(BSD::Resource) for package: mod_perl-2.0.4-10.el6.x86_64
---> Package mod_ssl.x86_64 1:2.2.15-15.el6_2.1 will be installed
---> Package mod_wsgi.x86_64 0:3.2-1.el6 will be installed
---> Package webalizer.x86_64 0:2.21_02-3.3.el6 will be installed
--> Processing Dependency: libgd.so.2()(64bit) for package: webalizer-2.21_02-3.3.el6.x86_64
--> Running transaction check
---> Package gd.x86_64 0:2.0.35-10.el6 will be installed
---> Package httpd-devel.x86_64 0:2.2.15-9.el6 will be updated
---> Package httpd-devel.x86_64 0:2.2.15-15.el6_2.1 will be an update
---> Package httpd-tools.x86_64 0:2.2.15-9.el6 will be updated
---> Package httpd-tools.x86_64 0:2.2.15-15.el6_2.1 will be an update
---> Package perl-BSD-Resource.x86_64 0:1.29.03-3.el6 will be installed
---> Package perl-ExtUtils-MakeMaker.x86_64 0:6.55-127.el6 will be installed
--> Processing Dependency: perl = 4:5.10.1-127.el6 for package: perl-ExtUtils-MakeMaker-6.55-127.el6.x86_64
--> Processing Dependency: perl(Test::Harness) for package: perl-ExtUtils-MakeMaker-6.55-127.el6.x86_64
--> Processing Dependency: perl-devel for package: perl-ExtUtils-MakeMaker-6.55-127.el6.x86_64
---> Package perl-Newt.x86_64 0:1.08-26.el6 will be installed
--> Running transaction check
---> Package perl.x86_64 4:5.10.1-119.el6 will be updated
--> Processing Dependency: perl = 4:5.10.1-119.el6 for package: 1:perl-Module-Pluggable-3.90-119.el6.x86_64
--> Processing Dependency: perl = 4:5.10.1-119.el6 for package: 3:perl-version-0.77-119.el6.x86_64
--> Processing Dependency: perl = 4:5.10.1-119.el6 for package: 1:perl-Pod-Simple-3.13-119.el6.x86_64
--> Processing Dependency: perl = 4:5.10.1-119.el6 for package: 1:perl-Pod-Escapes-1.04-119.el6.x86_64
--> Processing Dependency: perl = 4:5.10.1-119.el6 for package: 4:perl-libs-5.10.1-119.el6.x86_64
---> Package perl.x86_64 4:5.10.1-127.el6 will be an update
---> Package perl-Test-Harness.x86_64 0:3.17-127.el6 will be installed
---> Package perl-devel.x86_64 4:5.10.1-127.el6 will be installed
--> Processing Dependency: perl(ExtUtils::ParseXS) for package: 4:perl-devel-5.10.1-127.el6.x86_64
--> Running transaction check
---> Package perl-ExtUtils-ParseXS.x86_64 1:2.2003.0-127.el6 will be installed
---> Package perl-Module-Pluggable.x86_64 1:3.90-119.el6 will be updated
---> Package perl-Module-Pluggable.x86_64 1:3.90-127.el6 will be an update
---> Package perl-Pod-Escapes.x86_64 1:1.04-119.el6 will be updated
---> Package perl-Pod-Escapes.x86_64 1:1.04-127.el6 will be an update
---> Package perl-Pod-Simple.x86_64 1:3.13-119.el6 will be updated
---> Package perl-Pod-Simple.x86_64 1:3.13-127.el6 will be an update
---> Package perl-libs.x86_64 4:5.10.1-119.el6 will be updated
---> Package perl-libs.x86_64 4:5.10.1-127.el6 will be an update
---> Package perl-version.x86_64 3:0.77-119.el6 will be updated
---> Package perl-version.x86_64 3:0.77-127.el6 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================
 Package                                     Arch                       Version                                  Repository                 Size
=================================================================================================================================================
Installing:
 crypto-utils                                x86_64                     2.4.1-24.2.el6                           unixgeek                      76 k
 mod_perl                                    x86_64                     2.0.4-10.el6                             unixgeek                     3.2 M
 mod_ssl                                     x86_64                     1:2.2.15-15.el6_2.1                      unixgeek                      87 k
 mod_wsgi                                    x86_64                     3.2-1.el6                                unixgeek                      65 k
 webalizer                                   x86_64                     2.21_02-3.3.el6                          unixgeek                     128 k
Updating:
 httpd                                       x86_64                     2.2.15-15.el6_2.1                        unixgeek                     812 k
 httpd-manual                                noarch                     2.2.15-15.el6_2.1                        unixgeek                     781 k
Installing for dependencies:
 gd                                          x86_64                     2.0.35-10.el6                            unixgeek                     142 k
 perl-BSD-Resource                           x86_64                     1.29.03-3.el6                            unixgeek                      35 k
 perl-ExtUtils-MakeMaker                     x86_64                     6.55-127.el6                             unixgeek                     291 k
 perl-ExtUtils-ParseXS                       x86_64                     1:2.2003.0-127.el6                       unixgeek                      43 k
 perl-Newt                                   x86_64                     1.08-26.el6                              unixgeek                      72 k
 perl-Test-Harness                           x86_64                     3.17-127.el6                             unixgeek                     230 k
 perl-devel                                  x86_64                     4:5.10.1-127.el6                         unixgeek                     421 k
Updating for dependencies:
 httpd-devel                                 x86_64                     2.2.15-15.el6_2.1                        unixgeek                     147 k
 httpd-tools                                 x86_64                     2.2.15-15.el6_2.1                        unixgeek                      70 k
 perl                                        x86_64                     4:5.10.1-127.el6                         unixgeek                      10 M
 perl-Module-Pluggable                       x86_64                     1:3.90-127.el6                           unixgeek                      38 k
 perl-Pod-Escapes                            x86_64                     1:1.04-127.el6                           unixgeek                      30 k
 perl-Pod-Simple                             x86_64                     1:3.13-127.el6                           unixgeek                     210 k
 perl-libs                                   x86_64                     4:5.10.1-127.el6                         unixgeek                     576 k
 perl-version                                x86_64                     3:0.77-127.el6                           unixgeek                      49 k

Transaction Summary
=================================================================================================================================================
Install      12 Package(s)
Upgrade      10 Package(s)

Total download size: 18 M
Is this ok [y/N]: y


Sunday, March 10, 2013

How to generate Linux system performance report?

[root@client10 ~]# sadf -t  -d /var/log/sa/sa03 -- -r -dp -n DEV 7200 -s 00:00:00 -e 23:59:59
# hostname;interval;timestamp;kbmemfree;kbmemused;%memused;kbbuffers;kbcached;kbcommit;%commit
client10;7199;2013-03-03 02:00:01;138340;882516;86.45;33176;545328;545876;17.69
client10;7199;2013-03-03 04:00:01;116028;904828;88.63;41836;552344;545876;17.69
client10;7199;2013-03-03 06:00:01;112856;908000;88.94;42972;554272;545876;17.69
client10;7199;2013-03-03 08:00:01;109260;911596;89.30;44076;556752;545876;17.69
client10;7199;2013-03-03 10:00:01;108152;912704;89.41;45164;556788;546004;17.70
client10;7199;2013-03-03 12:00:01;106904;913952;89.53;46268;556828;546004;17.70
client10;7199;2013-03-03 14:00:01;105664;915192;89.65;47348;556872;546004;17.70
client10;7199;2013-03-03 16:00:01;104424;916432;89.77;48484;556904;546004;17.70
client10;7199;2013-03-03 18:00:01;103308;917548;89.88;49588;556960;546004;17.70
client10;7199;2013-03-03 20:00:01;115460;905396;88.69;50720;544508;546132;17.70
client10;7199;2013-03-03 22:00:01;114352;906504;88.80;51840;544552;546132;17.70
# hostname;interval;timestamp;DEV;tps;rd_sec/s;wr_sec/s;avgrq-sz;avgqu-sz;await;svctm;%util
client10;7199;2013-03-03 02:00:01;sda;0.11;0.01;0.89;7.93;0.00;10.17;2.84;0.03
client10;7199;2013-03-03 02:00:01;vg_client1-lv_root;0.11;0.01;0.89;7.93;0.00;10.44;2.84;0.03
client10;7199;2013-03-03 02:00:01;vg_client1-lv_swap;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 04:00:01;sda;0.41;3.57;3.07;16.14;0.00;4.80;1.90;0.08
client10;7199;2013-03-03 04:00:01;vg_client1-lv_root;0.67;3.57;3.07;9.96;0.01;9.29;1.17;0.08
client10;7199;2013-03-03 04:00:01;vg_client1-lv_swap;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 06:00:01;sda;0.12;0.52;0.90;12.18;0.00;7.53;2.47;0.03
client10;7199;2013-03-03 06:00:01;vg_client1-lv_root;0.12;0.52;0.90;12.26;0.00;7.82;2.49;0.03
client10;7199;2013-03-03 06:00:01;vg_client1-lv_swap;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 08:00:01;sda;0.11;0.68;0.87;13.54;0.00;11.21;3.27;0.04
client10;7199;2013-03-03 08:00:01;vg_client1-lv_root;0.11;0.68;0.87;13.69;0.00;11.68;3.31;0.04
client10;7199;2013-03-03 08:00:01;vg_client1-lv_swap;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 10:00:01;sda;0.11;0.00;0.86;7.83;0.00;6.36;2.39;0.03
client10;7199;2013-03-03 10:00:01;vg_client1-lv_root;0.11;0.00;0.86;7.91;0.00;6.70;2.41;0.03
client10;7199;2013-03-03 10:00:01;vg_client1-lv_swap;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 12:00:01;sda;0.11;0.00;0.86;7.78;0.00;7.64;2.28;0.03
client10;7199;2013-03-03 12:00:01;vg_client1-lv_root;0.11;0.00;0.86;7.91;0.00;8.18;2.32;0.03
client10;7199;2013-03-03 12:00:01;vg_client1-lv_swap;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 14:00:01;sda;0.11;0.00;0.87;7.92;0.00;6.84;2.09;0.02
client10;7199;2013-03-03 14:00:01;vg_client1-lv_root;0.11;0.00;0.87;7.92;0.00;7.19;2.09;0.02
client10;7199;2013-03-03 14:00:01;vg_client1-lv_swap;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 16:00:01;sda;0.12;0.00;0.99;8.48;0.00;9.90;2.90;0.03
client10;7199;2013-03-03 16:00:01;vg_client1-lv_root;0.13;0.00;0.99;7.92;0.00;10.58;2.71;0.03
client10;7199;2013-03-03 16:00:01;vg_client1-lv_swap;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 18:00:01;sda;0.13;0.00;1.30;10.15;0.00;8.37;2.06;0.03
client10;7199;2013-03-03 18:00:01;vg_client1-lv_root;0.16;0.00;1.30;7.95;0.00;9.74;1.61;0.03
client10;7199;2013-03-03 18:00:01;vg_client1-lv_swap;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 20:00:01;sda;0.13;0.00;1.63;12.64;0.00;12.58;2.90;0.04
client10;7199;2013-03-03 20:00:01;vg_client1-lv_root;0.21;0.00;1.63;7.94;0.00;16.03;1.82;0.04
client10;7199;2013-03-03 20:00:01;vg_client1-lv_swap;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 22:00:01;sda;0.11;0.00;0.89;7.86;0.00;8.11;2.66;0.03
client10;7199;2013-03-03 22:00:01;vg_client1-lv_root;0.11;0.00;0.89;7.92;0.00;9.43;2.68;0.03
client10;7199;2013-03-03 22:00:01;vg_client1-lv_swap;0.00;0.00;0.00;0.00;0.00;0.00;0.00;0.00
# hostname;interval;timestamp;IFACE;rxpck/s;txpck/s;rxkB/s;txkB/s;rxcmp/s;txcmp/s;rxmcst/s
client10;7199;2013-03-03 02:00:01;lo;0.00;0.00;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 02:00:01;eth1;0.01;0.01;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 04:00:01;lo;0.00;0.00;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 04:00:01;eth1;0.01;0.01;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 06:00:01;lo;0.00;0.00;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 06:00:01;eth1;0.01;0.01;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 08:00:01;lo;0.00;0.00;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 08:00:01;eth1;0.01;0.01;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 10:00:01;lo;0.00;0.00;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 10:00:01;eth1;0.01;0.01;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 12:00:01;lo;0.00;0.00;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 12:00:01;eth1;0.01;0.01;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 14:00:01;lo;0.00;0.00;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 14:00:01;eth1;0.01;0.01;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 16:00:01;lo;0.00;0.00;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 16:00:01;eth1;0.01;0.01;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 18:00:01;lo;0.00;0.00;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 18:00:01;eth1;0.01;0.01;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 20:00:01;lo;0.00;0.00;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 20:00:01;eth1;0.01;0.01;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 22:00:01;lo;0.00;0.00;0.00;0.00;0.00;0.00;0.00
client10;7199;2013-03-03 22:00:01;eth1;0.01;0.01;0.00;0.00;0.00;0.00;0.00
[root@client10 ~]#

Tuesday, March 5, 2013

How to find "Cores per socket" -or- "threads per core" -or- "CPU socket" in Redhat Linux?

Note: This works fine in RHEL 6 and above. (Not sure about previous versions)
# lscpu 
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                16
On-line CPU(s) list:   0-15
Thread(s) per core:    2
Core(s) per socket:    4
CPU socket(s):         2
NUMA node(s):          2
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 26
Stepping:              5
CPU MHz:               2533.876
BogoMIPS:              5065.97
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              8192K
NUMA node0 CPU(s):     0,2,4,6,8,10,12,14
NUMA node1 CPU(s):     1,3,5,7,9,11,13,15

Sunday, February 24, 2013

How to find where netwrok bandwidth is going on a given server?

Hint: Use "iftop -P" command.

How to find processes which are causing most IO to disks?

Hint: Use command "iotop -P"

How to find open ports and PID relation?


[root@client1 ~]# lsof -i
COMMAND     PID    USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
rpcbind    1361     rpc    6u  IPv4   8648      0t0  UDP *:sunrpc
rpcbind    1361     rpc    7u  IPv4   8652      0t0  UDP *:realm-rusd
rpcbind    1361     rpc    8u  IPv4   8653      0t0  TCP *:sunrpc (LISTEN)
rpcbind    1361     rpc    9u  IPv6   8655      0t0  UDP *:sunrpc
rpcbind    1361     rpc   10u  IPv6   8657      0t0  UDP *:realm-rusd
rpcbind    1361     rpc   11u  IPv6   8658      0t0  TCP *:sunrpc (LISTEN)
avahi-dae  1398   avahi   13u  IPv4   8867      0t0  UDP *:mdns
avahi-dae  1398   avahi   14u  IPv4   8868      0t0  UDP *:41861
rpc.statd  1423 rpcuser    5u  IPv4   9169      0t0  UDP *:kerberos_master
rpc.statd  1423 rpcuser    8u  IPv4   9173      0t0  UDP *:56647
rpc.statd  1423 rpcuser    9u  IPv4   9177      0t0  TCP *:44453 (LISTEN)
rpc.statd  1423 rpcuser   10u  IPv6   9181      0t0  UDP *:33861
rpc.statd  1423 rpcuser   11u  IPv6   9185      0t0  TCP *:34178 (LISTEN)
cupsd      1500    root    6u  IPv6   9440      0t0  TCP localhost:ipp (LISTEN)
cupsd      1500    root    7u  IPv4   9441      0t0  TCP localhost:ipp (LISTEN)
cupsd      1500    root    9u  IPv4   9444      0t0  UDP *:ipp
sshd       1619    root    3u  IPv4   9994      0t0  TCP *:ssh (LISTEN)
sshd       1619    root    4u  IPv6   9996      0t0  TCP *:ssh (LISTEN)
master     1699    root   12u  IPv4  10218      0t0  TCP localhost:smtp (LISTEN)
master     1699    root   13u  IPv6  10220      0t0  TCP localhost:smtp (LISTEN)
httpd      1739    root    4u  IPv6  10463      0t0  TCP *:http (LISTEN)
qpidd      1759   qpidd   10u  IPv4  10564      0t0  TCP *:amqp (LISTEN)
sshd      20154    root    3u  IPv4  85260      0t0  TCP client1.unixgeek.com:ssh->192.168.122.1:41754 (ESTABLISHED)
sshd      20154    root    8u  IPv6  85310      0t0  TCP localhost:x11-ssh-offset (LISTEN)
sshd      20154    root    9u  IPv4  85311      0t0  TCP localhost:x11-ssh-offset (LISTEN)
httpd     30172  apache    4u  IPv6  10463      0t0  TCP *:http (LISTEN)
httpd     30173  apache    4u  IPv6  10463      0t0  TCP *:http (LISTEN)
httpd     30174  apache    4u  IPv6  10463      0t0  TCP *:http (LISTEN)
httpd     30175  apache    4u  IPv6  10463      0t0  TCP *:http (LISTEN)
httpd     30176  apache    4u  IPv6  10463      0t0  TCP *:http (LISTEN)
httpd     30177  apache    4u  IPv6  10463      0t0  TCP *:http (LISTEN)
httpd     30178  apache    4u  IPv6  10463      0t0  TCP *:http (LISTEN)
httpd     30179  apache    4u  IPv6  10463      0t0  TCP *:http (LISTEN)
sshd      32503    root    3r  IPv4 104270      0t0  TCP client1.unixgeek.com:ssh->192.168.122.1:44522 (ESTABLISHED)


How to find PIDs associated with a specific mount point or directory?

[root@server1 ~]# lsof +D /tmp 
COMMAND    PID USER   FD   TYPE             DEVICE SIZE/OFF  NODE NAME
Xorg      2145 root    3u  unix 0xffff880037a00380      0t0 13160 /tmp/.X11-unix/X0
gnome-ses 2231  gdm    8u  unix 0xffff8800d6c05680      0t0 13424 /tmp/.ICE-unix/2231
gnome-ses 2231  gdm   17u  unix 0xffff88007f916080      0t0 13552 /tmp/orbit-gdm/linc-8b7-0-aa1e644ce7ad
gnome-ses 2231  gdm   18u  unix 0xffff88007f917980      0t0 13555 /tmp/orbit-gdm/linc-8b7-0-aa1e644ce7ad
gnome-ses 2231  gdm   23u  unix 0xffff88007f971380      0t0 13800 /tmp/orbit-gdm/linc-8b7-0-aa1e644ce7ad
gconfd-2  2239  gdm   11u  unix 0xffff88007d592380      0t0 13484 /tmp/orbit-gdm/linc-8bf-0-606984a4c9463
gconfd-2  2239  gdm   15u  unix 0xffff88007f916380      0t0 13551 /tmp/orbit-gdm/linc-8bf-0-606984a4c9463
gconfd-2  2239  gdm   17u  unix 0xffff8800d7331c80      0t0 13653 /tmp/orbit-gdm/linc-8bf-0-606984a4c9463
gconfd-2  2239  gdm   19u  unix 0xffff8800d959e680      0t0 13810 /tmp/orbit-gdm/linc-8bf-0-606984a4c9463
gconfd-2  2239  gdm   21u  unix 0xffff880046d18980      0t0 14068 /tmp/orbit-gdm/linc-8bf-0-606984a4c9463
gconfd-2  2239  gdm   23u  unix 0xffff8800468f7080      0t0 14127 /tmp/orbit-gdm/linc-8bf-0-606984a4c9463
at-spi-re 2253  gdm   11u  unix 0xffff88007f937080      0t0 13739 /tmp/orbit-gdm/linc-8cd-0-148cfa3815bdc
at-spi-re 2253  gdm   12u  unix 0xffff88000a128980      0t0 13743 /tmp/orbit-gdm/linc-8cd-0-148cfa3815bdc
at-spi-re 2253  gdm   14u  unix 0xffff8800d95a6680      0t0 13782 /tmp/orbit-gdm/linc-8cd-0-148cfa3815bdc



How to find NFS-only process opened by a specific user?

# lsof -N  -u sge  -a
COMMAND     PID USER   FD   TYPE DEVICE    SIZE     NODE NAME
sge_execd  5251  sge  cwd    DIR   0,29    4096  4368270 /mtpt/nfstmp6/eda_spool/server1 (10.20.30.102:/vol/nfstmp6)
sge_execd  5251  sge  txt    REG   0,28 1917054    99454 /mtpt/grid/sge/sge-6.2u5/bin/lx24-amd64/sge_execd (10.20.30.72:/vol/grid)
sge_execd  5251  sge  mem    REG   0,28    8093  1716583 /mtpt/grid/sge/sge-6.2u5/lib/lx24-amd64/libcore.so (10.20.30.72:/vol/grid)
sge_sheph  6220  sge  cwd    DIR   0,29    4096  4520407 /mtpt/nfstmp6/eda_spool/server1/active_jobs/2050265.1 (10.20.30.102:/vol/nfstmp6)
sge_sheph  6220  sge  txt    REG   0,28 3002442    99445 /mtpt/grid/sge/sge-6.2u5/bin/lx24-amd64/sge_shepherd (10.20.30.72:/vol/grid)
sge_sheph  6220  sge    3u   REG   0,29    5454  4520411 /mtpt/nfstmp6/eda_spool/server1/active_jobs/2050265.1/trace (10.20.30.102:/vol/nfstmp6)
sge_sheph  8064  sge  cwd    DIR   0,29    4096 11745026 /mtpt/nfstmp6/eda_spool/server1/active_jobs/1963625.1 (10.20.30.102:/vol/nfstmp6)
sge_sheph  8064  sge  txt    REG   0,28 3002442    99445 /mtpt/grid/sge/sge-6.2u5/bin/lx24-amd64/sge_shepherd (10.20.30.72:/vol/grid)
sge_sheph  8064  sge    3u   REG   0,29    5490 11267154 /mtpt/nfstmp6/eda_spool/server1/active_jobs/1963625.1/trace (10.20.30.102:/vol/nfstmp6)
sge_sheph 11956  sge  cwd    DIR   0,29    4096  8754269 /mtpt/nfstmp6/eda_spool/server1/active_jobs/1217293.1 (10.20.30.102:/vol/nfstmp6)
sge_sheph 11956  sge  txt    REG   0,28 3002442    99445 /mtpt/grid/sge/sge-6.2u5/bin/lx24-amd64/sge_shepherd (10.20.30.72:/vol/grid)
sge_sheph 11956  sge    3u   REG   0,29    3880 13004799 /mtpt/nfstmp6/eda_spool/server1/active_jobs/1217293.1/trace (10.20.30.102:/vol/nfstmp6)
sge_sheph 27134  sge  cwd    DIR   0,29    4096  2680503 /mtpt/nfstmp6/eda_spool/server1/active_jobs/546332.1 (10.20.30.102:/vol/nfstmp6)
sge_sheph 27134  sge  txt    REG   0,28 3002442    99445 /mtpt/grid/sge/sge-6.2u5/bin/lx24-amd64/sge_shepherd (10.20.30.72:/vol/grid)
sge_sheph 27134  sge    3u   REG   0,29    4008  2680507 /mtpt/nfstmp6/eda_spool/server1/active_jobs/546332.1/trace (10.20.30.102:/vol/nfstmp6)



How to find processes or PID associated with an open PORT?

[root@server1 ~]# lsof -i :80
COMMAND   PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
httpd    1740   root    5u  IPv6  11430      0t0  TCP *:http (LISTEN)
httpd   20923 apache    5u  IPv6  11430      0t0  TCP *:http (LISTEN)
httpd   20924 apache    5u  IPv6  11430      0t0  TCP *:http (LISTEN)
httpd   20925 apache    5u  IPv6  11430      0t0  TCP *:http (LISTEN)
httpd   20926 apache    5u  IPv6  11430      0t0  TCP *:http (LISTEN)
httpd   20927 apache    5u  IPv6  11430      0t0  TCP *:http (LISTEN)
httpd   20928 apache    5u  IPv6  11430      0t0  TCP *:http (LISTEN)
httpd   20929 apache    5u  IPv6  11430      0t0  TCP *:http (LISTEN)
httpd   20930 apache    5u  IPv6  11430      0t0  TCP *:http (LISTEN)
httpd   20931 apache    5u  IPv6  11430      0t0  TCP *:http (LISTEN)

[root@server1 ~]# lsof -i :22
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
sshd     1129 root    3u  IPv4 609767      0t0  TCP 10.20.30.11:ssh->10.20.30.230:54074 (ESTABLISHED)
sshd     1207 root    3u  IPv4 610131      0t0  TCP 10.20.30.11:ssh->10.20.30.230:54077 (ESTABLISHED)
sshd     1629 root    3u  IPv4  10946      0t0  TCP *:ssh (LISTEN)
sshd     1629 root    4u  IPv6  10948      0t0  TCP *:ssh (LISTEN)
sshd     6352 root    3u  IPv4 621398      0t0  TCP 10.20.30.11:ssh->10.20.30.230:54319 (ESTABLISHED)
ssh      8905 root    3u  IPv4 652131      0t0  TCP 192.168.122.1:41754->client1:ssh (ESTABLISHED)
sshd    21430 root    3r  IPv4 675462      0t0  TCP 10.20.30.11:ssh->10.84.64.173:52323 (ESTABLISHED)
sshd    30917 root    3r  IPv4 754268      0t0  TCP 10.20.30.11:ssh->10.20.30.230:55741 (ESTABLISHED)

[root@server1 ~]# lsof -i :80 -t
1740
20923
20924
20925
20926
20927
20928
20929
20930
20931


How to find port opened by a process?


[root@server1 ~]# ps -eaf | grep  20927 
apache   20927  1740  0 03:32 ?        00:00:00 /usr/sbin/httpd


[root@server1 ~]# lsof -p 20927 -i -a
COMMAND   PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
httpd   20927 apache    5u  IPv6  11430      0t0  TCP *:http (LISTEN)
httpd   20927 apache    7u  IPv6  11434      0t0  TCP *:https (LISTEN)