Monday, March 07, 2011
Solaris Performance Monitoring & Tuning – iostat, vmstat, netstat
Tuesday, December 22, 2009
Change Shell to Bash in Unix
edit /etc/passwd file and change shell (you need to login as root user):
Last filed is shell
From
To
link - http://www.cyberciti.biz/faq/howto-set-bash-as-your-default-shell/
# vi /etc/passwdLast filed is shell
From
vivek:x:1000:1000:vivek,,,:/home/vivek:/bin/shTo
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
Thursday, November 12, 2009
Perl/AWK/SED One-Liners
- cat htmlist | perl -nle 'print$1 if m/^(.*)_public_access.log_stats.html/' > complist.txt
- wc -l
| awk '{print $1}'
- cat file_name | awk 'NR > 11'
- perl -ne 'print if 1..100' FILE_NAME
- find . -name "*.log" -print | awk '{print "rm " $1}' | sh
- ls *html | perl -nle 'print $2 if m/^(.*)_i001_(.*)_reduced_(.*).html/' | sort | uniq
- grep -f file-1.txt file-2.txt | uniq
- sed 's/$/SUFFIX_TXT/' original_file.txt > new_file.txt
- perl -pi -e "s/host=\'([^\']*)\'/host=\'host.com\'/g" *.xml
- for i in *.jar; do echo $i; jar tvf $i | grep com.linkedin.geo; done;
- 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: awk, one-liners, perl, sed
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
fgrep -V "regexp"
head -50
Ctrl-r -> to auto complete a previously entered command
cd - -> to swap btw current and previously visited dir
!
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)
ls -1 --> to list files one per line with no other details ( its one not l )
time
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
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: auxww, commands, fgrep, head, linkedin, unix
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 "{}" \;
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 "{}" \;