Home  |   Guest Book |    Technical Page |    Personal Page   

Important Commands
 
About Me
Who is a Good QA
Latest News
Testing Concepts
Automation Tools
Agile Development
UNIX Basics
Perl Scripting
Python Scripting
MySQL
Technology
Repository
Imp. Commands
My Resume

1. connect to mysql

            mysql -h $dbServer -u $dbUser -p$dbPass -Bse 'show databases

2. Use of head and tail

            odbcinst -j | head -2 | tail -1| cut -d: -f2

3. For untarring

            gtar -xvf <tar file name> -C<target directory>

4. For tarring

            gtar -cf <tar file name with complete path>  <files to be compressed>

5. To get info of odbc

            odbcinst -j

6. To connect to mysl using telnet

            mysql -h <ipaddress> -D <database> -u <username> -p <password>

 

6.5 Create a user named Joe with the password Joe552 and grant all privileges when logging in from any host.

     */  GRANT ALL ON *.* TO Joe@'%' IDENTIFIED BY "Joe552"; 

      /* Verify the grant. */               SHOW GRANTS FOR Joe@'%';


 

7. To tar and untar files:

            Tarring  : tar -cvf PSDManager.tar PSDManager/

            Untarring: tar -xvf PSDManager.tar

8. If no. of db connection exhausted

            show variables;

            set global max_connection=500;

            set max_connections=500;

9. Find string in file in path /

            find / -type f -exec grep -l "String" {} \;

10. To find text in file:

            find . -print|grep 19AA & B

            find .  | xargs grep DATATYPE_REQUEST_RFMAP_CREATE

            find .  | xargs grep "PROCESSING AN MSC DUMPS"

11. find pid on some port

            /usr/bin/ps -ef -o pid -o args | grep <port no>

            pwdx <pid>

12. Add user

            useradd -s -m -d /export/home/akhil/ akhil

            passwd akhil

            usermod -d /export/home/qateam qateam

13. command set replaces job ID 7 to job ID 0 in all the ZK files present in

            for i in zk*

            do

            perl -p -i -e 's/FILE 7/FILE 0/g' $i

            done

            for i in zk*.txt;do perl -p -i -e 's/FILE 10/FILE 11/g' $i; done

            for i in *.gz; do  gunzip $i; done

14. CPU data

            /usr/platform/`uname -i`/sbin/prtdiag

15. balancing port from one machine to other. when other machine is not directly connected

login as root.

            cd /usr/local/sbin/

            ./balance -f 2402 192.168.24.66:23    TELNET

            ./balance -f 2403 192.168.24.66:3333            GUI - AMS-TRITON

            ./balance -f 2404 192.168.24.66:8080 &    DPC GUI

16. To start VNC

            export PATH=/usr/openwin/bin/:/opt/sfw/bin:/usr/sbin:/usr/bin

            cd /opt/sfw/bin/

            vncserver

17. Print basic information currently available from the system

            uname -a

18. Prints type of file

            file <file name>

19. To start Mysql server

    Login as root user on the machine and go to the directory

                        cd /var/lib/mysql/  <Check your databases are in which directory they are usually in the path>

            cd /opt/mysql/mysql/

            nohup ./bin/safe_mysqld --datadir=/var/lib/mysql/ &

            nohup ./bin/safe_mysqld --basedir=/opt/mysql/mysql --datadir=/var/lib/mysql &

   Mysql server starts.

21. To start syslog

            /user/sbin/syslogd

22. To kill syslogd

            pkill -HUP syslogd

23. Grant all privelges to a user:

            GRANT ALL PRIVILEGES ON *.* TO 'mysql'@'%' IDENTIFIED BY 'mysql' WITH GRANT OPTION;

            GRANT ALL PRIVILEGES ON *.* TO 'mysql'@'blade20' IDENTIFIED BY 'mysql' WITH GRANT OPTION;

24. Use the command on the Solaris servers to mount any folder:

            mount -F nfs 172.16.33.102:/polaris /path/to/mount/point

            mount -F nfs 172.16.33.102:/polaris /local/f880-4disk1/home/polaris

25. To get info on Sparc machine:

            /usr/platform/sun4u/sbin/prtdiag -v

26. To get size of folder:

            du -s <dir_path>

            du -sk *

27. get pid on port number binary is running

            ./lsof -i |grep ":50006"

            lsof commeands

            lsof -i :<portnumber>         : Find the process opening a particular port

            lsof -i | grep 'LISTEN'       : Shows all listening ports

            lsof -p <ProcessID>           : List paths that process id has open

            lsof ~                        : List processes that have specified path open ???

28. To create symbolic link

            ln -s /export/space/common/archive /archive

            ln -s  /local/f880-5disk1/home/globallogic/StreetPro/USUS

29. To check ipaddress:

            sed 's|[0-9]\{1,3\}\.\{1\}[0-9]\{1,3\}\.\{1\}[0-9]\{1,3\}\.\{1\}[0-9]\{1,3\}|172.16.33.109|g' z_check.txt > z.txt

30. To check registered RPC services

            rpcinfo -p

31. Last command ran of ps

            !ps

32. scp command

            scp -r root@<ip>:<path_to_copy> .

 

33. Perl index function ,

             my $result = index($string, $char, $offset);

             my $result = index($string, $substr);

 

34. Find process id:

             "ps" -aef | grep RgpsFtpClient | awk '{print  $9}'

 

35. Get details of solaris machine:  

             /usr/sbin/prtdiag

 

36. Untar at different location:         

             cat /path/of/tar/abc.tar | tar xf

 

37. Space in use:                                     

             df -lk | egrep -v "Filesystem|/proc|/dev/fd|swap" | awk '{ total_kbytes += $2 } { used_kbytes += $3 } END { printf "%d of %d kilobytes in use.\n", used_kbytes, total_kbytes }'

 

38. Memory in machine :                    

             /usr/sbin/prtconf | grep Memory

 

39. No of processor in machine:      

             psrinfo

 

40. To Check Perl Modules installed:

             Perl MExpect e print\Module Installed\\n\;

             Perl MTie::Hash e 1

 

41. Get no of lines between Line from 15 25 :                    

             tail +25 test.pl | head -10

 

42. insert a line "ABCDEF" at every 100th line of a file?

                  sed '100i\ABCDEF' file1

 

43. grep a line and cut it space using sed

      Below example will give you processid of the perl script running

             ps -eaf | grep HealthCheck.pl | grep "/usr/bin/perl" | awk '{print $3}'

 

44. Write a command sequence to find all the files modified in less than 2 days and print the record count of each.

                 find . -mtime -2 -exec wc -l {} \;

 

45. How can we find the process name from its process id?

            We can use "ps -p ProcessId"

 

46. top command options

       top - display top CPU processes

       -d     Specifies the delay between screen updates. You can change this with the s interactive command.

       -q     This causes top to refresh without any delay.

        -i      Start top ignoring any idle or zombie processes.        

        -n     Number of iterations. Update the display this number of times and then exit

        -b     Batch mode. Useful for sending output from top to other programs or to a file

 

 

 

 

 <SMTP configuration.>

    Follow the steps given below to configure SMTP on solaris box

            1)       Edit file /etc/mail/sendmail.cf

                        a.       Write

                                    DSsmtp-out-del1.globallogic.com

                        in new line just below line

                                    # "Smart" relay host (may be null)

            2)       Create file /etc/mail/relay-domains containing line

                                    172.16

                         The idea is to list the IP of subnet that connect to SMTP server

            3)       Restart SMTP server as 

                        a.       /etc/init.d/sendmail stop

                        b.      /etc/init.d/sendmail start

    Test the SMTP:

            1)       Make telnet connection to SMTP server at port 25

            2)       Write following commands on telnet window

                        a.       HELO localhost

                        b.      HELO localhost      //Yes, need to repeat the line again, Dont ask me why J

                        c.       MAIL FROM: Me

                        d.      RCPT TO: <a@b.com>

                        e.       DATA

                        f.                    This is a second test mail message

                        g.      .                                   //This is dot in list line

                        h.                                           //This is blank line


Copyright 2009 Kunal Saxena Inc. All rights reserved