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


 

No comments:

Post a Comment