Monday, May 18, 2009

Linux Commands

PREPARED BY M.T. BIPIN KUMAR V 1.0

  • How to kill a Process ??
    ps -elf grep java
    kill -9 number
    Or
    ps -Af
    ps -Af grep java

    kill -9 16840
    kill -9 process id
    =============================================================
    How to find Currentily running process are.
    ps -elf grep java
    =============================================================
    How to copy the directory?

    cp -R en /var/TestBroker/ --from current location
    =============================================================
    How to remove the folder ?
    rm -rf myfolder
    OR
    rm -R myfolder
    =============================================================
    How to remove all files from linux folder ?
    rm
    or
    rm -f *.txt //-f for deleting with out any prompt
    =============================================================
    How to clear the history in liunx box?
    history -c
    =============================================================
    How to unzip a file?
    zip is using compressed zip
    unzip >>filename>>.zip
    unzip j2ssh-core-0.2.9.zip
    refer: http://www.aota.net/Telnet/unzip.php4
    =============================================================
    How to tarz and un tarz a file?
    tar -czvf 60x80.tgz 60x80
    tar -xvzf 60x80.tgz

    tar -czvf doc.tgz BIPINSITE Order Process UserManual.doc
    tar -czvf product_idres.xml.tgz product_idres.xml
    =============================================================
    How to tar an untar a file?
    tar -czvf 60x80.tar 60x80
    tar -xvzf 60x80.tar

    tar -czvf 120x160.tar 120x160
    tar -xvzf 120x160.tar
    =============================================================================
    How to tar a file
    tar -czvf QueryRes.tar QueryRes.txt
    tar -czvf MasterCatalogReport.tar MasterCatalogReport.txt
    =============================================================
    How to find the no of files in side a folder?
    ls -l awk '!/^d/{print }' wc -l
    =============================================================
    How to find some files on linux server? :)
    find /opt/IBM/WebSphere/AppServer/profiles/mysite/installedApps/WC_mysite_cell/WC_mysite.ear/Stores.war/BIPINSITE/images/tempfld/ -name "*.jpg"
    =============================================================
    How to find and REMOVE some files on linux server? :)

    pls this command>> REMOVE

    find /opt/IBM/WebSphere/AppServer/profiles/mysite/installedApps/WC_mysite_cell/WC_mysite.ear/Stores.war/BIPINSITE/images -name "tempfld" -exec rm -rf {} \;

    find /opt/IBM/WebSphere/AppServer/profiles/mysite/installedApps/WC_mysite_cell/WC_mysite.ear -name "CVS" -exec rm -rf {} \;

    find /home/wcuser/DevelopmentMileStone/SourceCode/WebSphereCommerceServerExtensionsLogic/src -name "CVS" -exec rm -rf {} \;

    find /home/wcuser/DevelopmentMileStone/SourceCode/WebSphereCommerceServerExtensionsLogic/src -name "CVS" -exec rm -rf {} \;

    find /home/wcuser/DevelopmentMileStone/SourceCode/WebSphereCommerceServerExtensionsData/com -name "CVS" -exec rm -rf {} \;

    find /home/wcuser/DevelopmentMileStone/SourceCode/WebSphereCommerceServerExtensionsData/com -iname "*.class" -exec rm -rf {} \;
    =============================================================================
    How to find and save the result to one out put file?
    find / -iname "*.doc" > /home/catalogupload/t.txt

    find /home/ -iname "*.bk" > /home/catalogupload/t.txt

    find / -iname "*.bk" > /home/catalogupload/t.txt

    find /home/catalogupload/ -iname "*.bk" -exec rm -rf {} \;
    =================================================================================
    How to se Search file content in the linux files ?
    find -iname grep

    find /opt/IBM/WebSphere/AppServer/ -iname *.properties grep "BIPINSITE"

    find /home/catalogupload/archive/ -iname *.* grep 03100081015EG6182

    find /home/catalogupload/archive/ -iname wnmf.* grep "FLORENTINE"

    find /home/catalogupload/archive/ -iname *.* grep "FLORENTINE"

    grep -a images/marketing *.properties
    grep a text_to_find *.*
    =================================================================================
    How to move files from one server to another file
    BEWARE

    scp -r /path/filename user@servername:targetpath/
    scp -r /home/wcuser/fileExchange/FilesFromFP/FPOLimages/sorted.zip wcuser@182.168.4.55:/home/wcuser/fileExchange/FilesFromFP/

    scp -r QueryRes.txt wcuser@100.100.1.100:/home/wcuser/fileExchange/filesFromMT/

    scp -r QueryRes.txt wcuser@182.168.4.49:/home/wcuser/fileExchange/FilesFromMT
    =============================================================================
    How to handle "Argument list too long" when copying/deleting/moving files on Linux?
    http://www.electrictoolbox.com/argument-list-too-long-linux/

    find thumbnails/ -name "*.*" xargs -i mv {} myfolder/

    find 60x80/ -name "*.*" xargs -i mv {} /opt/IBM/WebSphere/AppServer/profiles/mysite/installedApps/WC_mysite_cell/WC_mysite.ear/Stores.war/BIPINSITE/images/catalog/thumbnails/
    find 120x160/ -name "*.*" xargs -i mv {} /opt/IBM/WebSphere/AppServer/profiles/mysite/installedApps/WC_mysite_cell/WC_mysite.ear/Stores.war/BIPINSITE/images/catalog/fullimage/
    find 60x80/ -name "*.*" xargs -i mv {} /opt/IBM/WebSphere/AppServer/profiles/mysite/installedApps/WC_mysite_cell/WC_mysite.ear/Stores.war/mysite/images/catalog/thumbnails/
    =============================================================================
    How to unrar a file in linux?
    unrar X images_CM.rar
    =============================================================================
    How to check the port number is open in linux?
    netstat -anp --tcp
    netstat -plan
    nmap -sT -O localhost
    netstat -an or lsof -i
    =============================================================================
    Server commands Http commands
    HTTPS:
    nmap ipaddress
    sh startServer.sh server1
    sh stopServer.sh server1
    httpd restart
    chkconfig --list httpd
    chkconfig httpd on
    chkconfig httpd off off the httpd
    ifconfig


    oracle:
    netmgr

    service httpd start
    =============================================================================
    IBM HTTP Server start/stop in stage:
    Command to start:
    path /opt/IBMIHS/bin/
    Stage ./apachectl -f /opt/IBM/WebSphere/CommerceServer60/instances/mysite/httpconf/httpd.conf -k start


    Dev Server ./apachectl -f /opt/IBM/WebSphere/CommerceServer60/instances/mysite/httpconf/httpd.conf -k start

    Command to stop ./apachectl stop
    =============================================================================
    Oracle Listener:
    su - oracle
    lsnrctl start
    lsnrctl status
    =============================================================================
    Dev image location?
    /opt/IBM/WebSphere/AppServer/profiles/mysite/installedApps/WC_mysite_cell/WC_mysite.ear/Stores.war/BIPINSITE/images/

    =============================================================================
    How to run the .sh command if .sh have the bash
    . filename.sh
    =============================================================================
    How to run java files?
    compile with package name
    javac -d /var/TestBroker/WEB-INF/classes/ -classpath /var/TestBroker/WEB-INF/classes/ JBRSource.java

    run file with file name
    java -classpath /var/TestBroker/WEB-INF/classes/ Test
    =============================================================================
    For getting the console of the tom cat in linux
    /dev/null 2>&1

    =============================================================================
    How to know about the environment/
    env > /tmp/mycommandline.env

    =============================================================================
    List all the contents from the direcoty:
    less >>direcotry Name>>
    =============================================================================
    Find the folder size
    ls -l awk '!/^d/{print }' wc -l
    =============================================================================
    How to check the free memory?/space
    free -m
    =============================================================================
    how to ping the server?
    ping -i .2 -c 5 beta.mysite.com.sg

    ping -i .2 -c 5 www.beta.mysite.com.sg
    =============================================================================
    cat /proc/cpuinfo

    Server CPU information
    =============================================================================
  • how to get the number of active connection using sql?

select sum(decode(status, 'ACTIVE',1,0)) from v$session where type= 'USER';