Some Linux/Unix command to help QA Activities

—————————

Linux/Unix Commands

—————————

See IP Address: ifconfig

See directory :: ls, li, ls

Create directory:: mkdir NAME

go to directory:: cd NAME

go to root :: \

delete directory :: rm -rf NAME

delete force fully directory :: rm -rf NAME

move file :: mv logs/error_log logs/ error_log1

copy file :: cp -rf pdf/abc.pdf            test/abc.pdf

copy file all files \cp -rf pdf/* test/

Find process:: ps -ef “processname”

Find Process :: ps -ef | grep java

Kill process:: kill -9 processid, killall procmail

Find and replace::  find . -name conf.xml

Grep Command:: grep “my name is prince” test/PrinceJain

Grep and count no of times: grep “my name is prince” test/PrinceJain | wc -l

set date:: date -s “2 OCT 2006 18:00:00″, date -s “Sun Nov  30 02:09:31 IST 2008″

run process in backend :: nohup php GetName.php &

start stop service::

service iptables stop

/etc/rc.d/init.d/iptables stop

/etc/rc.d/init.d/iptables start

/etc/init.d/mysql restart

/etc/init.d/mysql stop

/etc/init.d/mysql start

To do empty file:: >error_log , cat error_log

To change file/folder permission :: chmod -R 777 upload

To see tail for log file::tail -f FileName

To do file transfer from one machine to another (Unix/Linux)::

scp -r root@192.168.1.13:/home/prince/abc.txt  jain/

scp –r prince/abc root@192.168.1.12:/home/prince/

To do file transfer from one machine to another (Linux to windows)::

(First install pscp in window machine)

pscp.exe -r root@192.168.1.13:/home/root/prince.png  .

pscp.exe -r C:\ prince.png root@192.168.1.12:/home/prince/

To broadcast message ::

type “wall” , then whatever you want to say (multiple

lines are OK), followed by and then CTRL-D

—————————

CVS Commands

—————————

check out :: cvs co name

update :: cvs update name

diffrence :: cvs diff name

—————————

Vi editor Commands

—————————

open file–vi file name

save and close– :wq

quite without save– :q

save forcefull without save — :q!

find and replace –

:%s/localhost/192.168.1.13/

:%s/localhost/192.168.1.13/g

:%s/localhost/192.168.1.13/gc

प्राचीन यूनान में सुकरात नाम के विद्वान हुए हैं। वे ज्ञानवान और विनम्र थे। एक बार वे बाजार से गुजर रहे थे तो रास्ते में उनकी मुलाकात एक परिचित व्यक्ति से हुई। उन सज्जन ने सुकरात को रोककर कुछ बताना शुरू किया। वह कहने लगा कि ‘क्या आप जानते हैं कि कल आपका मित्र आपके बारे में क्या कह रहा था?’

सुकरात ने उस व्यक्ति की बात को वहीं रोकते हुए कहा - सुनो, भले व्यक्ति। मेरे मित्र ने मेरे बारे में क्या कहा यह बताने से पहले तुम मेरे तीन छोटे प्रश्नों का उत्तर दो। उस व्यक्ति ने आश्चर्य से कहा - ‘तीन छोटे प्रश्न’।

सुकरात ने कहा - हाँ, तीन छोटे प्रश्न।
पहला प्रश्न तो यह कि क्या तुम मुझे जो कुछ भी बताने जा रहे हो वह पूरी तरह सही है?
उस आदमी ने जवाब दिया - ‘नहीं, मैंने अभी-अभी यह बात सुनी और …।’
सुकरात ने कहा- कोई बात नहीं, इसका मतलब यह कि तुम्हें नहीं पता कि तुम जो कहने जा रहे हो वह सच है या नहीं।’

अब मेरे दूसरे प्रश्न का जवाब दो कि ‘क्या जो कुछ तुम मुझे बताने जा रहे हो वह मेरे लिए अच्छा है?’ आदमी ने तुरंत कहा - नहीं, बल्कि इसका ठीक उल्टा है। सुकरात बोले - ठीक है। अब मेरे आखिरी प्रश्न का और जवाब दो कि जो कुछ तुम मुझे बताने जा रहे हो वह मेरे किसी काम का है भी या नहीं।
व्यक्ति बोला - नहीं, उस बात में आपके काम आने जैसा तो कुछ भी नहीं है। तीनों प्रश्न पूछने के बाद सुकरात बोले - ‘ऐसी बात जो सच नहीं है, जिसमें मेरे बारे में कुछ भी अच्छा नहीं है और जिसकी मेरे लिए कोई उपयोगिता नहीं है, उसे सुनने से क्या फायदा। और सुनो, ऐसी बातें करने से भी क्या फायदा।

Aisee Vani Boliye, Mun Ka Aapa Khoye,
Apna Tan Sheetal Kare, Auran Ko Sukh Hoye!

  • final – constant declaration.
  • finally – The finally block always executes when the try block exits, except System.exit(0) call. This ensures that the finally block is executed even if an unexpected exception occurs. But finally is useful for more than just exception handling — it allows the programmer to avoid having cleanup code accidentally bypassed by a return, continue, or break. Putting cleanup code in a finally block is always a good practice, even when no exceptions are anticipated.
  • finalize() – method helps in garbage collection. A method that is invoked before an object is discarded by the garbage collector, allowing it to clean up its state. Should not be used to release non-memory resources like file handles, sockets, database connections etc because Java has only a finite number of these resources and you do not know when the garbage collection is going to kick in to release these non-memory resources through the finalize() method.

In simple words::

final variables are unchangeable.
final classes are not subclassed.
final methods are not overriden.

finilize() to clean up memory resourses for object using finilize().

finally block is executed if exception thrown or not.

Bura Jo Dekhan Main Chala, Bura Naa Milya Koye
Jo Munn Khoja Apnaa, To Mujhse Bura Naa Koye