Showing posts with label UNIX. Show all posts
Showing posts with label UNIX. Show all posts

Friday 13 May 2016

UNIX / LINUX Commands for Oracle DBA





  1) Basic Commands
  2) File and directory related commands
  3) Listing Commands
  4) Performance related commands
  5) Networking related commands
  6) Other commands

 

 Basic Commands



  $date --- To display the date and time of system.
  $cal--- To display the calender of the year.
      $cal 2013
      $cal 2014
      $cal 8 2014
      $cal 6 2011
      $cal 9
  $who--- To display all the users who curretly connected to the server
  $whoami --- To display information about you
  $su --- To switch from one user to another user.

       first login in to the server as root user, then switch to oracle user as below
  
       $su - oracle
  $clear --- To clear the window screen.
  $exit --- To exit from current user.
  $login --- To login to server using your username and passwd.
  $logout --- To logout of the current session.
  $banner --- To display the character or work followed by this command.

       $banner HYDERABAD
  $init 0 ---To shutdown the server or system
  $init 6 --- To restart the server or system
  $find--- To find a specific file in the current locaion.
  $which --- To find the location of executable you are using currently.
 
          $which sqlplus
  $uname -a ---- To display which OS is running and its version.
  $ps ---- To display current user processes information
  $ps -ef --- To display all current user processes plus system processes information
  $ps -ef|grep "process name" --- To display a specific process among many processes.
  $gzip xxx.txt --- To zip or compress a file on unix and linux side
  $gunzip xxx.txt.gz --- To unzip or uncompress a file
  $man ---- To get information/manual of a command.
 
        $man gzip

  $scp ---- To copy a file from one server to another server.

      $scp xxx.txt oracle@rr2.oracle.com:/u01/sales/

  $ping --- To check whether a ip address is reachable or not

     $ping 192.168.1.1

  $

 



FILE AND DIRECTORY Related commands


  Creating a new file :

   $cat > xxx.txt -- To create a new file using this. after typing a over..just press control + c.
   $touch zzz.txt --- To create a new empty file.
   $vi aaa.txt --- To create a new file in VI editor. if you want to insert data into this file, press on i key and type.
   $touch .abc.txt --- To creat empty hidden file.
  

 Copying a file :

   $cp /u01/xxx.txt /u02/
   $cp /u01/sales/xxx.txt   /u01/hdfc
  
 Moving a file

  $mv /u01/xxx.txt  /u02
  $mv /u02/abc/ttt.txt /u02/sales/

 Renaming a file

  $mv xxx.txt  yyy.txt(new name)

 Deleting or removing a file

  $rm xxx.txt
  $rm -f xxx.txt

 Directory related commands :



 

 creating a directory

  $mkdir /u02/movie
  $mkdir -p /u02/movie/hindi/krish (with -p option we can create all inner sub directories at a time along with main directoy)

 coping a directorty:

 $cp -r /u02/movie  /u03

 moving a directory :

 $mv -r /u02/movie  /u04

 Deleting or removing a directory :

 $rm -rf /u02/movie

 renaming a directory :

 $mv movie movie_new


 Performance related commands :


  $top  

 This command is going to display following information..

  * Server avg load
  * number of tasks are currently running on the server
  * current cpu Usage on the server
  * current memory usage on the server
  * which process is consuming high CPU and memory on the server
  * other information.

 $sar  (system activity report)

  This display's the report of system activity

   $sar 2 5 ( This display's report of the system activity for every 2 seconds until 5 times)

 $iostat ( This is to check what is the io statistics on the devices of the server. This display's the stats of
inputs (reads) per second and output (write) per second.

 $free ( this display's the free RAM MEMORY and swap memory information on the server)

 $vmstat ( This display's the virtual memory stats on the system)



 Network related commands :

  $/sbin/ifconfig -a  -- This is to find out the ip address and any packates drop over the network. this is similar to ipconfig on windows side.

  $netstat -- This is to find out the network stats on the server
 
  $nslookup 99.88.77.9  --- This is to find out the server(hostname) detatils of we know the ip address

 Listing commands :

  $ls -- To list out all the directories and files under a specific file system (/u01)
  $ls -a -- To display all the hidden files under a specific location

  $ls -i --- To display the inode number of the files and folders..whenever we create a file or folder on the unix/linux side,
os assignes a unique number to those files, it is called inode number.

  $ls -r -- displays  the files and folders in reverse order..this is opposite to ls command

  $ls -l -- displays the files and folders in the long listing order

  $ls -lt -- display the fiels and folders in time order that are crated.

  $ls -ltr --- display the files and folders in reverse,timely and long listing order.


  Other commands :

  #useradd --- to add a user account at OS level..this is generally done by OS ADMIN but not a dba.

  #userdel -- to delete a user account at os level.

  #groupadd -- to add a group at os level

  #groupdel --to delete a group at os level

  #chmod -- to change permission of a file or folder.

    #chmod 775 xxx.txt

  #chown -- to change the ownership of a file or folder

    $chown -R oracle:oinstall /u01/app.


  #df -h -- to display the disk free (all file systems) on the server

  #du -sh xxx.txt  -- to display the size of a file or folder in a specific location (/u01)

  #more xxx.txt --- to display the file content page by page. press spacebar on the keypad if you want to see the content page by page.

  #wc -l --- to get work count(wc)  in the a specific location

  #echo -- to print the text after the echo


      #echo $SHELL
 
      #echo $ORACLE_SID


 

Shutting Down a Database


To shut down a database and instance, you must first connect as SYSOPER or SYSDBA.

·         Shutting Down with the NORMAL Clause
·         Shutting Down with the IMMEDIATE Clause
·         Shutting Down with the TRANSACTIONAL Clause
·         Shutting Down with the ABORT Clause


 Shutting Down with the NORMAL Clause

To shut down a database in normal situations, use the SHUTDOWN command with the NORMAL clause:
SQL> SHUTDOWN NORMAL
The NORMAL clause is optional, because this is the default shutdown method if no clause is provided.
Normal database shutdown proceeds with the following conditions:
·         No new connections are allowed after the statement is issued.
·         Before the database is shut down, the database waits for all currently connected users to disconnect from the database.
The next startup of the database will not require any instance recovery procedures.


Shutting Down with the IMMEDIATE Clause

Immediate database shutdown proceeds with the following conditions:
·         No new connections are allowed, nor are new transactions allowed to be started, after the statement is issued.
·         Any uncommitted transactions are rolled back. (If long uncommitted transactions exist, this method of shutdown might not complete quickly, despite its name.)
·         Oracle Database does not wait for users currently connected to the database to disconnect. The database implicitly rolls back active transactions and disconnects all connected users.
The next startup of the database will not require any instance recovery procedures.


Shutting Down with the TRANSACTIONAL Clause

When you want to perform a planned shutdown of an instance while allowing active transactions to complete first, use the SHUTDOWN command with the TRANSACTIONAL clause:
SQL> SHUTDOWN TRANSACTIONAL
Transactional database shutdown proceeds with the following conditions:
·         No new connections are allowed, nor are new transactions allowed to be started, after the statement is issued.
·         After all transactions have completed, any client still connected to the instance is disconnected.
·         At this point, the instance shuts down just as it would when a SHUTDOWN IMMEDIATE statement is submitted.
The next startup of the database will not require any instance recovery procedures.


Shutting Down with the ABORT Clause

You can shut down a database instantaneously by aborting the database instance.
When you must do a database shutdown by aborting transactions and user connections, issue the SHUTDOWN command with the ABORT clause:
SQL> SHUTDOWN ABORT
An aborted database shutdown proceeds with the following conditions:
·         No new connections are allowed, nor are new transactions allowed to be started, after the statement is issued.
·         Current client SQL statements being processed by Oracle Database are immediately terminated.
·         Uncommitted transactions are not rolled back.
·         Oracle Database does not wait for users currently connected to the database to disconnect. The database implicitly disconnects all connected users
.


Tuesday 10 May 2016

How to search for Specific text in Alert Log

vi and vim have powerful searching capabilities because they bring to bear the richness of regular expressions.

To search for the next occurence of the text ‘ORA’ from the current cursor position, type:

/ORA

Search backward from the current position by using  ' ? '  instead of / in the command.

Once you have searched for something, you can find the next occurrence by pressing n or the previous occurrence with N .

Searching in vi/vim is enhanced with regular expressions.
For example, to find the next occurence of the text ‘ORA’ that occurs at the beginning of a line, use:
/^ORA

Monday 9 May 2016

Unix related Oracle DBA Interview

Questions:
1. How do you see how many instances are running?
2. How do you automate starting and shutting down of databases in Unix?
3. You have written a script to take backups. How do you make it run automatically every week?
4. What is OERR utility?
5. How do you see Virtual Memory Statistics in Linux?
6. How do you see how much hard disk space is free in Linux?
7. What is SAR?
8. What is SHMMAX?
9. Swap partition must be how much the size of RAM?
10. What is DISM in Solaris?
11. How do you see how many memory segments are acquired by Oracle Instances?
12. How do you see which segment belongs to which database instances?
13. What is VMSTAT?
14. How do you set Kernel Parameters in Red Hat Linux, AIX and Solaris?
15. How do you remove Memory segments?
16. What is the difference between Soft Link and Hard Link?
17. What is stored in oratab file?
18. How do you see how many processes are running in Unix?
19. How do you kill a process in Unix?
20. Can you change priority of a Process in Unix?

Sunday 17 April 2016

How To add swap space on linux system


 Follow Below Steps to add swap space in Linux :


1. login to root user
su root

2. create swap file for desired size
dd if=/dev/zero of=/swapfile1 bs=1024 count=524288

NOTE: bs = size in bytes and count = ( bs * desired space)
if you want to increase 1g then count will calculate in following way
1024 * 1024 = 1048576

3. setup linux swap area
# mkswap /swapfile1

4. Activiate swapfile space
# swapon /swapfile1

5. check "free-m" command on # prompt
$ free -g

check for more info: http://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/