4

I just installed Oracle Database 11g R2 on Ubuntu.

I tried to run sqlplus but I got this message :

sqlplus: command not found

These are the values of : $ORACLE_SID, $ORACLE_HOME and $PATH

aimad@localhost:/u01/app/oracle/product/11.2.0/dbhome_2/bin$ echo $ORACLE_SID

aimad@localhost:/u01/app/oracle/product/11.2.0/dbhome_2/bin$ echo $ORACLE_HOME
/u01/app/oracle/product/11.2.0/dbhome_2/
aimad@localhost:/u01/app/oracle/product/11.2.0/dbhome_2/bin$ echo $PATH
/usr/local/sbin:/sbin:/usr/sbin:/bin:/usr/bin:/usr/bin/X11:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/root/bin

How can I solve this problem ?

Edit :

I tried to enter to the /u01/app/oracle/product/11.2.0/dbhome_2/bin and run the ./sqlplus command instead of sqlplus and it worked, but I want to execute sqlplus without entering to that path everytime.

  • How did you install the package? Via apt? A .deb? – Mitch Oct 10 '14 at 16:19
  • @musher I installed the .deb which I downloaded from Oracle's website – Aimad Majdou Oct 10 '14 at 16:20
  • Try this and report back the results: sudo find /usr /bin /sbin /root -name sqlplus – Mitch Oct 10 '14 at 16:26
  • @musher it returns nothing :/, please see the edit I made to my question – Aimad Majdou Oct 10 '14 at 16:29
  • The installation should have placed a small shell script named oraenv in /usr/bin or /usr/local/bin. If you type . oraenv, does it make your shell's PATH include the /u01/app/oracle/product/11.2.0/dbhome_2/bin directory? – Mark Plotnick Oct 10 '14 at 22:17
6

The easiest solution for you I believe is to add a soft link in /bin to the actual location of the binary.

ln -s /u01/app/oracle/product/11.2.0/dbhome_2/bin/sqlplus /bin/sqlplus

This will allow all users to call sqlplus from wherever.

  • your example command is referencing a different directory than the one you mentioned prior. – MGodby Oct 10 '14 at 16:37
  • Good point, fixed that. Strictly speaking it would've worked eitherway since /usr/bin is on his PATH – Mitch Oct 10 '14 at 16:39
  • Yes, and if we wanted to stick to tradition, we'd create the link into /usr/bin, but it doesn't really matter from a practical perspective. – MGodby Oct 10 '14 at 16:40
2

You have many options here, but I will list what I believe to be the easiest/simplest.

Note: each of these is an independent solution. These do not compose a series of steps.

  1. Locate the actual sqlplus binary and add that directory to your path. This relatively-ancient post is still extremely relevent for this task: askubuntu - how to add a directory to my path

  2. Locate the binary and create a soft link to the bin directory in your user's home directory. Here is the command for that:

    ln -s /u01/app/oracle/product/11.2.0/dbhome_2/bin/sqlplus $HOME/bin/sqlplus
    

    Alternatively for all users to have this functionality:

    sudo ln -s /u01/app/oracle/product/11.2.0/dbhome_2/bin/sqlplus /usr/bin/sqlplus
    


  3. Create an alias that calls the binary via its full path through environment variables. This tutorial gives you instructions for how to do that: askubuntu - How to create a permanent alias

    The line for your alias would look like this:

    alias sqlplus='/u01/app/oracle/product/11.2.0/dbhome_2/bin/sqlplus'
    


  4. Call the command directly by specifying the entire path every time:

    /u01/app/oracle/product/11.2.0/dbhome_2/bin/sqlplus
    
  • 1
    when I tried the first command I got this message : ln: failed to create symbolic link ‘/home/aimad/bin/sqlplus’: No such file or directory – Aimad Majdou Oct 10 '14 at 16:37
  • I do not see a message. If it was complaining that "file or directory does not exist", create your directory first with mkdir $HOME/bin – MGodby Oct 10 '14 at 16:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.