Wednesday, March 31, 2010

Unix commands

Tune tcp parameters in Solaris
--------------------------------------
e.g.
Set command:  /usr/sbin/ndd -set /dev/tcp tcp_local_dack_interval 20
Get command: /usr/sbin/ndd /dev/tcp tcp_deferred_acks_max

Replace text in a file
------------------------
sed 's/old-string/new-string/g' filename

Find files with multiple file extensions
------------------------
ls -ltr `find directory_path -type f \( -name "*.bak" -o -name "*.old" -o -name "*.2" -o -name "*.copy" -o -name "*.tmp" -o -name "*.swp" -o -name "*.~" \) -print`

Get IP
------------------------
grep IPADDR /etc/sysconfig/network-scripts/ifcfg-eth0  |awk -F= '{print $2}'

Get hostname
------------------------
cat /proc/sys/kernel/hostname

Get last two characters in a word
-----------------------------------
string=test
echo ${string:(-2)}
The result will be 'st'

Monitor system stats
----------------------
vmstat 1 2

iostat -xn 1
mpstat 1


Free memory on Linux
-------------------
free -m

Print no. of CPUs
--------------------
psrinfo -p

NFS mount command
-----------------------
Solaris: mount -F nfs {nas_name}:{source_volume_directory} {target_directory}
Ex: mount -F nfs mynas:/vol/data_environment/env /opt/nascontent

Linux: Solaris: mount -t nfs {nas_name}:{source_volume_directory} {target_directory}

Find out if Redhat is 32 or 64 bit
---------------------------------
Run command: uname -a

Output from 32 bit host:
Linux hostname 2.6.18-92.el5 #1 SMP Tue Apr 29 13:16:12 EDT 2008 i686 i686 i386 GNU/Linux

Output from 64 bit host:
Linux hostname 2.6.18-92.el5 #1 SMP Tue Apr 29 13:16:15 EDT 2008 x86_64 x86_64 x86_64 GNU/Linux

64 bit systems will have x86_64 in their output and 32 bit systems will not have this flag.


================
Useful commands:

fdisk -l | more

grep -ir string
/sbin/iptables -L

service iptables stop
chkconfig iptables off

Check TCP parameters values:
/usr/sbin/ndd /dev/tcp tcp_local_dack_interval

Labels: , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home

Newer›  ‹Older