misc_commands1
/opt/VRTSvxfs/sbin/vxrepquota /local/2 ==> to see quota limits on ftp.mydomain.com
Opsware package path = /home/opsware_util/scripts/deploy
######################################
To check CPU utilisation
# ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10
To sort process according to memory usage
ps -eo rss,pid,user,pcpu,time,stime,vsz,size,cmd:30 --sort=-rss,pid|head -5
========================================
scp/ssh to another host without being prompted for key verifications
scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ConnectTimeout=10 linux_su_root.sh $j:/tmp/
=======================================
tar cBf - <jobdirname>_xfer | /opt/krb5/bin/rsh -x -l root lonwebhost24 "cd /tmp && tar xBf -"
############################################
check perl module's path
perldoc -l <modulename>
############################################
Awk misc:
$ cat /etc/passwd|awk -F: '{print $1,$NF}'
root /bin/bash
bin /sbin/nologin
daemon /sbin/nologin
adm /sbin/nologin
lp /sbin/nologin
To have better formatting
$ cat /etc/passwd|awk -F: '{printf "%-10s %s\n",$1,$NF}'
root /bin/bash
bin /sbin/nologin
daemon /sbin/nologin
adm /sbin/nologin
lp /sbin/nologin
##########################
find *_xfer -name *-xfer|xargs grep -i <string>
find . -exec grep -l "SEARCH" {} \; | xargs -p perl -pi -e 's/SEARCH/REPLACE/g'
fgrep -lR loncvtp * |xargs perl -pi -e "s/loncvtp/loncvts/g"
find /local/0 -type f -size +100000k -exec ls -lh {} \; to search files consuming more than 100MB space.
#####################
fgrep -xvf file1 file2
diplays the lines of file2 which are not present in file1.
fgrep -xf file1 file2
displays the lines which are present in both files
============================
Command for deployment in Sun web Server 7
export CLI="$WS_INST_DIR/wadm"
export WS_INST_DIR="/opt/sunjsws/int/bin"
export WADM_CREDS="--user=admin --password-file=/var/tmp/adm.pw"
export ADMIN_PORT="29178"
ssh -q root@$host "$CLI deploy-config $WADM_CREDS --host=$host --port=$ADMIN_PORT --no-ssl --force $INSTANCE";
###########################
j=50
for ((i=1; i <= ${j}; ++i));do echo $i;done
for ((i=1; i <= ${j}; ++i));do head -${i} /var/tmp/sysmgt/netdev_200312|tail -1;done
###########################
Enable core dumps
in /etc/security/limits.conf
* soft core unlimited
In /etc/profile (Redhat)
# No core files by default
# ulimit -S -c 0 > /dev/null 2>&1 (uncomment it to enable core dumps)
In /etc/init.d/functions (Redhat)
# make sure it doesn't core dump anywhere unless requested
# ulimit -S -c ${DAEMON_COREFILE_LIMIT:-0} >/dev/null 2>&1 (uncommet this)
* Location of core files
in /etc/sysctl.conf add below
kernel.core_pattern = /local/0/cores/core.UID-%u.PID-%p
* Check core file limit
#ulimit -a
* how to read core dump file
$strings <core dump file>
OR
$gdb <core dump file>
#####################
View teh output of Top command of remote machine
ssh linux10402 top -bn1
###################
Take thread dump
linux10402:/opt/beawls/11g/wlserver_10.3/server/bin$. ./setWLSEnv.sh
java weblogic.Admin -url t3://linux20848-i2.mydomain.com:8000 -username weblogic -password ILxIKuW0 THREAD_DUMP
######################
setup java heap memory dump
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/opt/logroot/jboss-vap
########################
Beajrockit additional JVM options
For verbose output: -Xgc:parallel -Xverbose:gc,cpuinfo,memory
For heap memory dump: -Djrockit.oomdiagnostics=true -Djrockit.oomdiagnostics.filename=/opt/myjeefarm/instances/tlm/integration/protected/logs/OOM.dump
----------------------------------
SUN JDK JVM options
For verbose: XX:+PrintGCDetails -XX:+PrintGCTimeStamps
For heap memory dump: -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/opt/myjeefarm/instances/tlm/production/protected/logs
########################
tcpdump host '(lobluecoatp1 or lobluecoatp2 or lobluecoatp3 or lobluecoatp4 or lobluecoatp5 or lobluecoatp6)'
######################
search and add string at particular place in file.
1.
>cat testsed
ravmane
singhr4
>sed -i 's/ravmane/ravmane\nbsinha/I' testsed - \n stands for new line charecter.
>cat testsed
ravmane
bsinha
singhr4
-------------------------------------
2.
-bash-3.00$ cat test
| user1 | email1 | edl1 | svc1 |
| user2 | email2 | edl2 | svc2 |
DEV
-bash-3.00$ perl -pi -e "s/^DEV/Ravi\nDEV/g" test
-bash-3.00$ cat test
| user1 | email1 | edl1 | svc1 |
| user2 | email2 | edl2 | svc2 |
Ravi
DEV
=============================================
sed 's/.*/&RAVi/' readme
OR
sed 's/\(.*\)/\1<\RAVI/' readme
This aapends word "RAVI" at end of each line in readme file
==================================================
$sed -i '1i\
ravi' README.ravitest.integration
Inserts ravi at the top of file called "README.ravitest.integration"
======================================================
$cat netdevices.txt
net1.mydomain.com
net2.mydomain.com
net3.mydomain.com
$sed 's/^.//g' netdevices.txt
net1.mydomain.com
net2.mydomain.com
net3.mydomain.com
"." deletes first character ie. blank char in this case
=======================================================
=======================================
diff text3 text4|egrep "<|>"|sed -e 's/^..//g'
Displays the fields which are not common in both files text3 and text4
diff text1 text2|egrep "<" - displays the fields of text1 which is not there in text2
=======================================================
send email with diferent id
echo "Test"|mail -s "test" biswajit.sinha@mydomain.com -- -f ravindra.mane@mydomain.com
=======================================================
gzgrep
http://farm.mydomain.com/TXPO/?__WebLogicBridgeConfig
http://myjeefarm.mydomain.com/?__WebLogicBridgeConfig
http://linux10401.mydomain.com/server-status
http://linux10401.mydomain.com/jkstatus
ypcat -k automount.src | grep pgp - to view the mount point for pgp
ypcat -k group|grep webtech - to view the members of group webtech
time curl http://myjeefarm-smpl-int-jb.mydomain.com/SMPL/jsp/test_delay.jsp?delaysecs=1
time curl http://myjeefarm-smpl-int-jb.mydomain.com/SMPL/jsp/test_delay.jsp?delaysecs=90
host -t ptr 10.81.116.158 ===> DNS reverse lookup
perl -e 'print "@INC"'- view installed perl modules
#################################################
Download file through curl
curl -v -x applicationwebproxy.mydomain.com:80 -u <username>:<password> -C - -O https://pfafeed.factiva.com/xml/pfa2_201010112200_d.zip
############################################
CVS commands
_________________
CVSROOT=${CVSROOT:-":pserver:lwtbacks@loncvs5:/home/eu_etg_source/infrastructure"};
CVSMODULE=${CVSMODULE:-configs}
CVSFILE="webservers/loncplive2/obj.conf"
DATE=`/usr/bin/date`
cvs -d $CVSROOT checkout $CVSMODULE/$CVSFILE
cvs -d $CVSROOT commit -m "$DATE: commiting $CVSFILE" $CVSMODULE
cvs -d $CVSROOT -Q release -d $CVSMODULE
############################################
######################
ravmane@linux10401:~/temp$ sed -i -e '/=lb-nsam-integration/a \worker.lb-nsam-integration.reference=worker.basic' workers.properties.integration
# This will search for line containing "=lb-nsam-integration" in the file "workers.properties.integration" and insert line "worker.lb-nsam-integration.reference=worker.basic" below that line
$for i in `cat workerslist`; do sed -i -e "/worker.list=$i/ a\worker.$i.reference=worker.basic" workers.properties.integration;done
#Above command takes the the word in "workerslist" file one by one and then search the line containg taht word in workers.properties.integration and then put the line "worker.<word taken>.reference=worker.basic" just below that line
###################################
to change Console prompt on linux: in .bashrc --> PS1="<`hostname`-$LOGNAME:\$PWD>
PS1='\u@\h:\w\$ '
vi .cshrc
#!/bin/csh
setenv SHELL '/bin/ksh'
/bin/ksh
PS1='\[\e]1;$UNAME\a\e]2;${PWD}\a\
\e[0;36m\]\
[\u@$UNAME \w] \
\[\e[m\]'
fgrep -lR {loncvtp} * |xargs perl -pi~ -e 's/{loncvtp}/loncvts/'
########## how to find smtp server in network #####
C:\Documents and Settings\8ravmane>nslookup
Default Server: LONDNS7.mydomain.com
Address: 10.69.0.1
> set type=mx
> set timeout=20
> mydomain.com
Server: dns.mydomain.com
Address: 10.69.0.1
mydomain.com MX preference = 10, mail exchanger = rewriter2.uk.mydomain.com
mydomain.com MX preference = 10, mail exchanger = rewriter3.uk.mydomain.com
mydomain.com MX preference = 10, mail exchanger = rewriter4.uk.mydomain.com
########################################################################
#tar ---.tar.bz2 {dir/files to bzip}
curl -v http://internal.mydomain.com - for verbose o/p
curl -I http://internal.mydomain.com - to get header info.
curl -x mbbluecoat01:80 -v http://internal.mydomain.com - access link through proxy server.
sysdef - Gives current shared mem settings on solaris host
for i in `find . -name instance-config`; do grep 239.200.11.3 $i; done
find "${PGPDIR}/bin/${JOB_NAME}"|xargs perl -pi -e "s#source-path=#source-path=${SOURCE_PATH}#g"
for i in 5200421 5190421; do ./deploy -u ravmane -p mydomain123 -a "$i" --servers "linux10381 linux10382 linux10383 linux10384 linux20326 linux20327 linux20328 linux20329" --core lab; done
Resatrt autofs:
[root@linux10674 ~]# ps -ef |grep -i auto
root 3151 3125 0 06:52 pts/1 00:00:00 grep -i auto
[root@linux10674 ~]# /etc/init.d/autofs restart
Stopping automount: [ OK ]
Starting automount: [ OK ]
$dig +identify myjeefarmprod.eu-gen2.gslb.mydomain.com
dig +short +identify myjeefarmint.eu-gen1.gslb.mydomain.com
curl -iv http://internalws.mydomain.com/MWEB/EU/process/ -u ravmane
if [$1 == "int"] || [$1 == "uat"] || [$1 == "prd"]
while true; do dig @lonux20006 nfsglobal-1.gbl1.gslb.mydomain.com +short; sleep 1; done
@lonux20006 - name of the name server (DNS server)
nfsglobal-1.gbl1.gslb.mydomain.com - name to be resolved
for i in `cat intservers`;do ./management.sh --query --report-instance-usage --instance int --server $i;done |tee intservers_usage
ypcat -k automount.src | grep pgp
########################################################################
SVN Commands
1. checkout the svn code:
/opt/svn/1.5.6/bin/svn checkout http://tksvng.mydomain.com/SVG/repos/mydomainNow/trunk/portal-infrastructure/nnconfgen/
2. To add new files: Go to the dir where new files resides.
/opt/svn/1.5.6/bin/svn add INT.tklx*
3. To commit:
Go the hoe of svn repo.
bash-3.00$ pwd
/home/sanpatil/repo/nnconfgen
bash-3.00$
/opt/svn/1.5.6/bin/svn commit -m "Added config files for web servers in tdc2" etc/web-intranet
########################################################################
svn checkout
svn status --show-updates
svn add
svn commit
svn diff -r 1:2 <file name>
=====================================================================
WLST
To enter in WLST shell:
WL_HOME="/opt/beawls/11g/wlserver_10.3"
ravmane@linux10401:/opt/myjeefarm/instances/bis-11g/integration/domain$ . setDomainEnv.sh
ravmane@linux10401:/opt/myjeefarm/instances/bis-11g/integration/domain$ /opt/beajrockit/jrockit-jdk1.6.0_14/bin/java weblogic.WLST
wls:/offline> connect("weblogic","vYXoQMZ2","t3://linux10404.mydomain.com:8520")
Connecting to t3://linux10404.mydomain.com:8520 with userid weblogic ...
Successfully connected to managed Server 'wls1' that belongs to domain 'bis-11g-integration'.
Warning: An insecure protocol was used to connect to the
server. To ensure on-the-wire security, the SSL port or
Admin port should be used instead.
wls:/bis-11g-integration/serverConfig>
==================================================
script To find process id of the process listenign on particular port on Solaris box
#!/bin/bash
# Get the process which listens on port
# $1 is the port we are looking for
if [ $# -lt 1 ]
then
echo "Please provide a port number parameter for this script"
echo "e.g. $0 22"
exit
fi
echo "Greping for your port, please be patient (CTRL+C breaks) ... "
for i in `ls /proc`
do
pfiles $i | grep AF_INET | grep $1
if [ $? -eq 0 ]
then
echo Is owned by pid $i
fi
done
#############################################################################
When to use double pipe (||) and &&
If the exit status of the first command is not 0, then execute the second command .
It's the opposite of '&&', where the second command is executed only if the exit status of the preceding command is 0.
For example:
Code:
$ ls this_file_does_not_exist.txt || echo OK
ls: cannot access this_file_does_not_exist.txt: No such file or directory
OK
$ ls this_file_exist.txt && echo OK
this_file_exist.txt
OK
#################################################
"logname" or "who am i" gives you the original user of multiple sudo sessions
#############################################
for i in `ls -1 /opt/myjeefarm/share/myjeefarm-repository/instances/*/integration/protected/instance-config`;do echo -e "########################################\n";echo -e "$i\n";cat $i|egrep "http|unix_adminuser|owner_email|owner_edl"|grep -v https;done
for i in `ls -1 /opt/myjeefarm/share/myjeefarm-repository/instances/*/integration/protected/instance-config`;do echo -e "########################################\n";echo Domain=`echo $i|awk -F/ '{print $7}'`;cat $i|egrep "http|unix_adminuser|owner_email|owner_edl"|grep -v https;done
for i in `ls -1 /opt/myjeefarm/share/myjeefarm-repository/instances/*/integration/protected/instance-config`;do echo -e "##################### #\n";echo Domain `echo $i|awk -F/ '{print $7}'`;cat $i|egrep "http|unix_adminuser|owner_email|owner_edl"|grep -v https;done|awk '{print $2}'|sed -e '/^$/d'
then in vi do - %j|%s/#/^M#/g|g/^$/d
#################################################
I have one file with below content.
$cat file1
#
web1
id1
user1
edl1
#
web2
id2
user2
edl2
#
web3
id3
user3
edl3
There are 5 lines after every "#" charecter. I want teh content of every line to be placed horizontally after #.
The file should look like the one below.
$cat file2
# web1 id1 user1 edl1
# web2 id2 user2 edl2
# web3 id3 user3 edl3
Answer:-) -
-----------
awk 'NR > 1 && /#/{$0 = "\n"$0}1' ORS=" " file
###################################################
$cat file1
| weblogic | bakejo | user1@example.com | user1@example.com | managed_server_linux10404.example.com_1_linux10404.example.com:8380 | managed_server_linux20491.example.com_2_linux20491.example.com:8380 |
| weblogic | bakejo | user1@example.com | user1@example.com | linux10404.example.com | linux20491.example.com |
I want to replace a pattern starting with managed and ending with second .com ( for example "managed_server_linux20491.example.com_2_linux20491.example.com") with only "managed".
i.e. final output should look like this
$cat file1
| weblogic | bakejo | user1@example.com | user1@example.com | managed:8380 | managed:8380 |
| weblogic | bakejo | user1@example.com | user1@example.com | linux10404.example.com | linux20491.example.com |
Answer:
sed 's/managed_server_.*_2_.*\.com/mamaged/g' file1
####################################################
On windows machine how to find Domain Controller
echo %logonserver%
##############################################
Perl for loop
for ( $i = 1; $i <= 5; $i++) {
print “loop $i\n”;
}
#########################################
Cut command
$ cat /tmp/netwin_devices
1,muwinc12-fwer01 ,163.124.80.253,Switch,other,Prod,IN-Networks-Support,mydomain.com,India
2,muwinc12-fwer01rbi,163.124.80.251,Router,other,Prod,IN-Networks-Support,mydomain.com,India
we need all fields from 2nd
ravmane@linux10401:/home/autoproxy$ cat /tmp/netwin_devices |cut -d, -f2-
muwinc12-fwer01 ,163.124.80.253,Switch,other,Prod,IN-Networks-Support,mydomain.com,India
muwinc12-fwer01rbi,163.124.80.251,Router,other,Prod,IN-Networks-Support,mydomain.com,India
##########################################
Wc -l equivalent in DOS:
findstr /R /N "^" file.txt | find /C ":"
ovownodeutil -list_nodes -group_path \OS_WIN -recursive|findstr /R /N "^"|find /C ":"
================================================
for loop in DOS
for %i in (host1 host2) do ovownodeutil -delete_node -node_name %i
========================================
run command in telnet from the shell
#(sleep 2;echo "scout_version";sleep 2) | telnet tkpvc01ux08gcd 9876
===========================================
I have below content in file:
Code:
$cat daemmoninver
+DEFAULT-linuxdaemon-tklxopswprod005 daemon ready
+DEFAULT-soldaemon-tksddvc01ux04fid daemon ready
3.127
+DEFAULT-soldaemon-tksdpvc01ux10pt daemon ready
3.127
+DEFAULT-linuxdaemon-tklxopswprod006 daemon ready
+DEFAULT-linuxdaemon-tklxopswprod007 daemon ready
+DEFAULT-linuxdaemon-tklxopswprod008 daemon ready
+DEFAULT-linuxdaemon-tklxopswprod009 daemon ready
+DEFAULT-linuxdaemon-tkodclxdbu2pora0-m daemon ready
+DEFAULT-linuxdaemon-tkodclxecomdev050 daemon ready
1.207
+fid-rtb-uny-rate-prd-jatk-tksdpvmc02lx004apex daemon ready
1.207
+DEFAULT-linuxdaemon-tkodcdvm01lx03ll daemon ready
1.207
I want to extract only those lines which are followed with the line having numbers(versions) i.e. 3.127,1.207
output should be:
Code:
+DEFAULT-soldaemon-tksddvc01ux04fid daemon ready
3.127
+DEFAULT-soldaemon-tksdpvc01ux10pt daemon ready
3.127
+DEFAULT-linuxdaemon-tkodclxecomdev050 daemon ready
1.207
+fid-rtb-uny-rate-prd-jatk-tksdpvmc02lx004apex daemon ready
1.207
+DEFAULT-linuxdaemon-tkodcdvm01lx03ll daemon ready
1.207
OR
+DEFAULT-soldaemon-tksddvc01ux04fid daemon ready
+DEFAULT-soldaemon-tksdpvc01ux10pt daemon ready
+DEFAULT-linuxdaemon-tkodclxecomdev050 daemon ready
+fid-rtb-uny-rate-prd-jatk-tksdpvmc02lx004apex daemon ready
+DEFAULT-linuxdaemon-tkodcdvm01lx03ll daemon ready
Solution:
If the values are 3.127 & 1.207, the command will be
Code:
egrep -w '3.127|1.207' daemmoninver -B1
If the values are different, the command will be
Code:
grep ^[012345789] daemmoninver -B1
=========================================================
Command line short cuts
< Command line - input >
Home or Ctrl + a
Move the cursor to the beginning of the current line.
End or Ctrl + e
Move the cursor to the end of the current line.
Alt + b
Move the cursor to the beginning of the current or previous word. Note that while this works in virtual terminals, it may not work in all graphical terminal emulators, because many graphical applications already use this as a menu shortcut by default.
Alt + f
Move the cursor to the end of the next word. Again, like with all shortcuts that use Alt as the modifier, this may not work in all graphical terminal emulators.
Tab
Autocomplete commands and file names. Type the first letter(s) of a command, directory or file name, press Tab and the rest is completed automatically! If there are more commands starting with the same letters, the shell completes as much as it can and beeps. If you then press Tab again, it shows you all the alternatives.
This shortcut is really helpful and saves a lot of typing! It even works at the lilo prompt and in some X applications.
Ctrl + u
Erase the current line.
Ctrl + k
Delete the line from the position of the cursor to the end of the line.
Ctrl + w
Delete the word before the cursor.
=========================================================
ldapsearch -x -LLL -h ldap.mydomain.com -D "uid=jbuat42,ou=consumers,ou=service accounts,l=global,o=mydomain.com" -w CXXXXX -b o=mydomain.com uid=maneravi dn
=======================================================
rsync command to copy with symlink,ownership, permissions and exclude directory
rsync -avzl --exclude 'lonecrmp/myjeefarm-logs' lonecrmp linux20693:/local/1/home/
---------------------------------------------------
Command to search logs for specific time range
This searches the logs from 14:00 till 22:00 on 14may
sed -n '/May 14 14:/,/May 14 22:/p' logfile