Monday, March 07, 2011

 

Solaris Performance Monitoring & Tuning – iostat, vmstat, netstat

http://adminschoice.com/iostat-vmstat-netstat

Labels: ,


Tuesday, December 22, 2009

 

Change Shell to Bash in Unix

edit /etc/passwd file and change shell (you need to login as root user):

# vi /etc/passwd

Last filed is shell
From
vivek:x:1000:1000:vivek,,,:/home/vivek:/bin/sh
To
vivek:x:1000:1000:vivek,,,:/home/vivek:/usr/local/bin/bash

Save and close the file.

link - http://www.cyberciti.biz/faq/howto-set-bash-as-your-default-shell/


Tuesday, November 17, 2009

 

SSH restart

How to I restart sshd

After you have changed your configuration on your remote Unix/linux server you must restart your ssh service.

The easiest way to do this is to simply restart your Unix machine. This is not always possible however.

To restart sshd without restarting your whole system, enter the following command

RedHat and Fedora Core Linux
service sshd restart

Suse linux
/etc/rc.d/sshd restart

Solaris 9 and below
/etc/init.d/sshd stop
/etc/init.d/sshd start

Solaris 10
svcadm disable ssh
svcadm enable ssh

AIX
stopsrc -s sshd
startsrc -s sshd

Labels: ,


Thursday, November 12, 2009

 

Perl/AWK/SED One-Liners

- list all the files but cut the last part "_public_access.log_stats.html"

- Prints part of the command output, wc -l would print ($1, $2) if you want both to be printed use awk '{print $1,$2}' - Reference

- Print lines after 11 in a file - Reference

- Print lines in a range , if you specify the end as 0 (zero) it will print all the lines starting from the begin range provided till the end of the file

- delete all find under all sub folders in a folder at once in one line. The cool thing here is piping to sh, which is same as piping it to a sh file and running it, all in one line

- list all files with the matching regular expression but only the part of the file name you need dont repeat if its already printed. ( sort is a unix command and uniq is also a unix command )

- this cmd will list all lines which are identical in 2 files. This is different than diff in the sense that it is not location sensitive, hence very useful for listing common contents/lines in files regardless of location.

- this one-line cmd will add suffix specified "SUFFIX_TXT" at the end of each line in the original_file.txt and pipe it to a new file

- This one-line cmd will go through all the XML files in a folder ( in this case 270, and apply the regular expression to all of them.

- This online command will do jar -tvf on all jars on all jars in the folders and the sub-folders, you can also do with with awk, but awk cant do sub-folder as we use grep there

  • find . -name "*.txt" | awk '{print "echo '"'test '"' >> " $1}' | sh
- This cmd will find all the files that match the regex recursively and append the text "test" to them
reference -

http://www.catonmat.net/blog/wp-content/uploads/2008/09/awk1line.txt

Labels: , , ,


Thursday, September 17, 2009

 

Unix Commands & Tricks

/usr/ucb/ps auxww -> This command will give detailed info about the processess

fgrep -V "regexp" -> Will list all the lines that DONT have this reg exp

head -50 -> prints the first 50 lines in a file ( same for tail )

Ctrl-r -> to auto complete a previously entered command

cd - -> to swap btw current and previously visited dir

! --> replay from history short cut

df -kh --> readable view of the Disk Space ( in GB - human readable )

du -skh . --> size of the current dir (in GB - human readable )

prtconf|grep Mem --> for finding the RAM size of the machine (Solaris)

isainfo -v --> To find out if your OS is 32 or 64 bit (Solaris)

ls -1 --> to list files one per line with no other details ( its one not l )

time [app/cmd] --> used to measure the time taken by the prog/cmd executed

pkill -9 java --> kills all java processes ( can be used to kill processes based on type )

ptree/pstree --> displays process and threads in a tree (solaris/linux)

ggrep -r "18025" `find . -name '*.pid'` --> grep for a expression in all files matching the pattern recursively

comm -23 file-1.txt file-2.txt --> print lines only in file-1 but not in file-2 ( refer to man comm for details )

hostname --> changes the hostname for good, if used without args prints hostname.

find . -name "*[0-9]" | awk '{ print "rm " $1}' | sh --> delete all files using regex ( in this case all file names ending with a number )

prtdiag - Best command to find the type of Processors/cores used in a unix system

iotop - Find which processes are Top users of IO in Unix

iostat - Lets you know the % of use of Reads/Writes of disk IO in a system

Labels: , , , , ,


Monday, September 14, 2009

 

recursive grep for a pattern in all subfolders

grep "perftest" * -R

Friday, September 11, 2009

 

How to Delete all files based on a regular exp across multiple folders

Use Case : How to delete something*.log across multiple folder in one shot

Command : find . -name "*public_access*.log" -exec rm "{}" \;



I would try to use a echo before arm it with violent behavior.

example : find . -name "*public_access*.log" -exec echo rm "{}" \;

This page is powered by Blogger. Isn't yours?