Thursday 20 March 2014

Linux commands

To check for hung ports use the following commands:-
netstat -an |grep tcp | sort +1 -n -r | head

Example of the output:-
tcp  0  0 192.168.1.12:61062  192.168.1.12:1521     ESTABLISHED

 Find a pid which owns a port:-
lsof -i:<PORT> |grep LISTEN

Example:-
[oracle@bharath database]$ lsof -i:1521|grep LISTEN
tnslsnr 7388 oracle   10u  IPv4  38217       TCP *:ncube-lm (LISTEN)

Find the process for a particular PID:-
ps -ef | grep <PID>
Example:-
[oracle@bharath database]$ ps -ef|grep 7388
oracle    7388     1  0 07:23 ?        00:00:00 /db_1/bin/tnslsnr LISTENER -inherit
oracle   16253 15997  0 07:36 pts/2    00:00:00 grep 7388
[oracle@bharath database]$

Display Number of Processors on Linux

[oracle@bharath database]$ cat /proc/cpuinfo|grep processor
processor    : 0
processor    : 1
processor    : 2

Find Memory Size

[oracle@bharath database]$ cat /proc/meminfo|grep MemTotal
MemTotal:      2075468 kB

[oracle@websphe ~]$ free  -m
             total       used         free      shared    buffers     cached
Mem:    2026       2003         22          0           93        497
-/+ buffers/cache:       1413        613

Swap:         4031          0       4031

Delete Files Older Than x Days on Linux
[oracle@bharath database]$ find *.trc -mtime +5 -exec rm {} \;

Find hostname and ip address
[oracle@bharath database]$ hostname
bharath.tech.com
[oracle@bharath database]$ hostname -i
192.168.1.12

Find largest file in unix
[oracle@bharath database]$ du -s *|sort -nr|tail -1
4       runInstaller


Find Version in linux
[oracle@bharath database]$ uname -a
Linux bharath.tech.com 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:43 EDT 2010 i686 i686 i386 GNU/Linux

Find version in AIX
# oslevel -r

Find Disk usage 
#dh -h

 Find  Disk Free info
[oracle@websphe ~]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2              74G   32G   38G  46% /
/dev/sda1             289M   16M  259M   6% /boot
tmpfs                1014M     0 1014M   0% /dev/shm



No comments: