Tuesday, 11 December 2012

RPM: unix Commands

RPM:

rpm -qa                       shows what rpm packages are installed
rpm -ql <package name>        shows where the files are installed (rpm -qlp .. shows the absolut paths???)
rpm -q --filesbypkg cdrecord  list all the files on installed rpm package
rpm -qf /usr/bin/lynx         query a file to find the source rpm package
rpm -qi <package name>
        list information on an installed rpm package
rpm -qR <package name>        list all dependencies on any rpm package
        
rpm -Uvh httpd-2.2.8.aix5.1.rpm install the rpm package

rpm -Uvh --force *.rpm
rpm -Uvh --force --nodeps <package name>    does not check dependency

rpm -e <package name> 
        removes the rpm package

/usr/sbin/updtvpkg            enables the rpm command to recognize that the libraries have been installed

In some cases you might get an error about failed dependencies when you install RPMs on AIX (for example, error: failed dependencies: libX11.a(shr4.o) is needed by tk-8.3.3-1). Most likely the error occurs because the rpm command does not recognize the shared library. If the error occurs, check to see if the X11 libraries are installed in the directory /usr/lpp/X11/lib. If they are not installed, use the AIX product media to install them. After you have installed the libraries, run the above command (updtvpkg). The command enables the rpm command to recognize that the libraries have been installed.

Thursday, 15 November 2012

Oracle HTTP server with Weblogic 10.3.4 with SSL



Issue:
First page will be HTTPS (because it will be entered in the browser as https)
Once the application page loads it will go to HTTP which is not secured page.
If we add S to HTTP, the page loads fine and probably works also.
Reason:
      It is issue with Web-logic version 10.3.4, which is by-default does not recognizing the “WL-Proxy-SSL” and hence Oracle HTTP server was not getting proper response.
                                                                                                                                                  
Solution:
      Enabling the Weblogic Plugin Enabled parameter from (Weblogic Console) the “Domain_Name --> Configuration Tab --> Web Applications Sub Tab”

Finding File Size in Linux, Aix, HP-UX



For Linux :find $DIR -type f -size +200000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
For AIX : find $DIR -type f -size +200000k -exec ls -l {} \; | awk '{ print $9 ": " $5 / 1048576 “MB” }'
For HPUX :find $DIR -type f -size +400000 -exec ls -l {} \; | awk '{ print $9 ": " $5 / 1048576 "MB" }'
                                                                                                                                                                              
Where $DIR = the directory where you want find files like /opt [ SIZE  OF FILE > 200000KB(195.31 MB) ].

To free pagecache in LINUX


echo 1 > /proc/sys/vm/drop_caches
 #To free dentries and inodes:
 echo 2 > /proc/sys/vm/drop_caches
 #To free pagecache, dentries and inodes:
 echo 3 > /proc/sys/vm/drop_caches
Note: you need to execute these as ROOT user                                                                                                                           

Generating heap dump in WAS

1. Start the wsadmin scripting client. You have several options to run scripting commands, ranging from running them interactively to running them in a profile.

2. Invoke the generateHeapDump operation on a JVM MBean, for example,
- Finding JVM objectName:
   <wsadmin> set objectName [$AdminControl queryNames WebSphere:type=JVM,process=<servername>,node=<nodename>,*]  
- Invoking the generateHeapDump operation on JVM Mbean:
   <wsadmin> $AdminControl invoke $objectName generateHeapDump
where, 
$is a Jacl operator for substituting a variable name with its value
invokeis the command
generateHeapDumpis the operation you are invoking
<servername>is the name of the server on which you want to generate a heap dump
<nodename>is the node to which <servername> belongs


3. Important to AMD 64-bit users: You must specify the -Xtrace option to take heap dumps.

Generating Heap Dump In Linux/Jboss/Sun JVM

jmap -dump:live,file=<location to save the file>/<filename>.hprof <PID>

jmap -F -dump:live,file=/home/heapdump/heapdump.hprof 2323
 
For 64 bit JVM (should take default but some times if you have multiple JAVA in the same box), use below option:-                                                                                                                   

jmap -J-d64 -dump:live,file=<location to save the file>/<filename>.hprof <PID>



NOTE: you have to run "jmap" from your <JAVA_HOME/bin>

Find Process associated with Port


In Linux:-
----------
netstat -tulpn
----------
In AIX:-
------------------
#netstat -Aan | grep Port_Number
==>Above command will Display the process who is holding the socket then use below command to get the Process ID.

#rmsock <Address_of_PCB> tcpcb
<Address_of_PCB> => is the output of previous command
-------------------                                                                                                                

Script to find Default JMS Queue Details in WAS

To get the default JMS Queue details in WAS (Web sphere Application Server), below “jacl” script can be used.
set perfName [$AdminControl queryNames WebSphere:type=SIBQueuePoint,name=QUEUE_NAME,process=server1,*"]

set identifier [$AdminControl getAttribute $perfName identifier]

puts [$AdminControl getAttributes $perfName]
Let say we have saved above script in file called “test.jacl”, then it can be executed from WAS_HOME/bin as below:-
./wsadmin.sh -lang jacl -user <user-id> -password <password> -conntype SOAP -port <SOAP-Port> -f test.jacl

Output Will be like:-

WASX7209I: Connected to process "server1" on node <NODE-NAME> using SOAP connector;  The type of process is: UnManagedProcess
WASX7303I: The following options are passed to the scripting environment and are available as arguments that are stored in the argv variable: "[QUEUE_NAME]"

{depth 0} {state ACTIVE} {id 94828E41C96C098B9A781FF9_QUEUE_189} {identifier QUEUE_NAME} {highMessageThreshold 50000} {sendAllowed true}

Perl script to KILL process with given name in Windows

Perl script to KILL process with given name in Windows.
This script is useful as part of any automated process that runs in Windows in order to kill a process with given name.

$|++; # force auto flush of output buffer
system("WMIC /OUTPUT:C:\\log.txt path win32_process get Processid,Commandline");
$infile1="C:/log.txt";
open(IN1,"<:encoding(UTF-16LE)","$infile1");
$profilename="<PROCESS_NAME>";
while(<IN1>)
{
            next if (/^(\s)*$/);#skip blank lines
            s/(\s)+$//g; #Removing white space at the end of line.
            if (/$profilename/)
            {
            print "$1\n" if (m/(\d+)$/);
            system("taskkill /F /PID $1");
            }
}
close(IN1);

Using grep (traditional UNIX way) to recover files - Deleted by rm -rf


Using grep (traditional UNIX way) to recover files

Use following grep syntax:
grep -b 'search-text' /dev/partition > file.txt
OR
grep -a -B[size before] -A[size after] 'text' /dev/[your_partition] > file.txt
Where,

    -i : Ignore case distinctions in both the PATTERN and the input files i.e. match both uppercase and lowercase character.
    -a : Process a binary file as if it were text
    -B Print number lines/size of leading context before matching lines.
    -A: Print number lines/size of trailing context after matching lines.

To recover text file starting with "nixCraft" word on /dev/sda1 you can try following command:
# grep -i -a -B10 -A100 'nixCraft' /dev/sda1 > file.txt

Next use vi to see file.txt. This method is ONLY useful if deleted file is text file. If you are using ext2 file system, try out recover command. .

Thursday, 20 September 2012

Important UNIX Commands!!

Important UNIX Commands!! 
Please find below important UNIX commands   which we generally use in our day to day activities.