Saturday, August 11, 2012

How to Install Oracle SQL Plus on Ubuntu 12.04

On my day to day work I have to deal with Oracle a lot! and since I am trying to use Ubuntu as my working environment I had to install a bunch of things one of them is SQL Plus. I like command line a lot and SQL plus is the best tool for Oracle so I had to have it.

The process is not so complicated. So let's start first you need to go to the Database Instant Client page and download the one specific to your platform. This post is for 32 bit so you have to download the Instant Client Downloads for Linux x86 one. It should be the same for the 54 bit though. From there you need to download these 2 rpm files:
  • Instant Client Package - Basic: All files required to run OCI, OCCI, and JDBC-OCI applications
  • Instant Client Package - SQL*Plus: Additional libraries and executable for running SQL*Plus with Instant Client
If you want, you can download the SDK :
  • Instant Client Package - SDK: Additional header files and an example makefile for developing Oracle applications with Instant Client
Since these are rpm files we need to convert them to deb, in order to that we need to install the alien utility
sudo apt-get install alien

Once that is done, go to the folder where the rpm files are located and execute the following
alien -i oracle-instantclient-basic*.rpm
alien -i oracle-instantclient-sqlplus*.rpm
alien -i oracle-instantclient-devel*.rpm

These commands will convert the rpm files on the fly and install them. Now you can test it by just typing sqlplus on the command line. For sure it will complain about a couple of things. One of them maybe about a missing . This one is easy, we just need to install it a simple
sudo apt-get install libaio1
The next error might be about missing libraries like The libraries are there but SQL Plus can't find them. We need to add them to our PATH this is easy as well. We just need to create an oracle.conf file inside /etc/ so lets do that. I use vi because I like it, but you can use whichever editor you want to create the file.
sudo vi /etc/
then we add this:
Notice that in my path I have 11.2 be careful with this. You can navigate and check that the path is correct for yours. 11.2 is the version we are installing. At the time of this post 11.2 was the latest one. Once you save the file we need to update the configuration by running:
sudo ldconfig

Now you should be ready to connect using:
sqlplus username/password@//dbhost:1521/SID

If you have problems with the SDK, you can check this post.
Hope it helps someone and happy coding!


  1. nice post. bt i can't login. plz help.
    What is the username and password?

  2. How do you create a new user and password to log in using sqlplus ?

  3. At the beginning you have to log in using the sys user something like this:
    sqlpus sys/[youpassword] as sysdba

    then create a user
    create user testuser identified by "password";

    then you can do:
    sqlplus testuser/password

    1. What is [youpassword] ?? I was never asked a password during installation

    2. hi, thank you for this helpful tutorial, i have a problem with username and pass, i used "sys" as user name and "sysdba" as password, but not working. can you pleas help me with that .
      thanks again

  4. Hi,
    it is a nice post, thank you.

    I did all the steps you described, and no error message have been diplayed. But at the final step:
    " sqlplus username/password@//dbhost:1521/SID "

    the terminal displays that:
    sqlplus: error while loading shared libraries: cannot open shared object file: No such file or directory

    Have you any idea about how to fix this?

    1. It's probably because the LD_LIBRARY_PATH was not set up. See the part about creating an oracle.conf file in the /etc/ directory. That should fix things for you.

    2. in order to solve this problem, type this comand sudo apt-get install libaio1 works fine to me.

  5. Very nice set of instructions. Thx!

  6. Works great, thanks!

  7. Hi, very helpful, but Can u tell me how to connect to the HR schema so that I can excute my queries on the already created tables in HR schema.
    Thank you.

  8. i have done all the above steps but when i type sqlplus in my terminal it is saying no command found

  9. Great job Marcelo...
    Working perfectly 32/64 bit Ubuntu and 12.1 oracle instant client too...
    Just changing the path to the libraries (/usr/lib/oracle/12.1/client64/lib)


  10. Hi, nice method of installation of Sql Plus on Ubuntu Os.I extremely helped in installing Sql Plus in Os.Thanks....


  11. Nice Post Bro, You solved my Problem. Really Very Helpful Post thanks a lot
    C Projects

  12. How can I access and manipulate the database through c++ programs?
    Please help....

  13. sqlplus: command not found

    I am getting this error !

  14. Received this error after 1st command trying to convert rpm to deb file. Please help!

    Unpacking of 'oracle-instantclient12.1-basic-' failed at /usr/share/perl5/Alien/Package/ line 168.

  15. I don't have initial USERNAME and PASSWORD! All attempts are giving errors. Please help as soon as posssible. I've tried with "SYS", "SYSTEM", "HR", . Nothing working.

  16. im getting this error while connecting.. please help:::

    sachin@sachin-OptiPlex-745:~/Downloads$ sqlplus username/password@//dbhost:1521/SID

    SQL*Plus: Release Production on Thu Nov 14 10:26:48 2013

    Copyright (c) 1982, 2013, Oracle. All rights reserved.

    ORA-12154: TNS:could not resolve the connect identifier specified

    Enter user-name:

  17. Hi,
    Have done all the details steps as per the given instruction. Have added path /usr/lib/oracle/12.1/client64/lib in oracle.conf file.

    Still getting the output sqlplus: command not found when trying sqlplus.

    Request to help. thanks


  18. please help me solve these error in ubuntu

    ORA-12154: TNS:could not resolve the connect identifier specified

  19. please help with these ERROR:
    ORA-12545: Connect failed because target host or object does not exist

  20. I am facing problm in installing 3 rpm packages....pls help me....facing problm package not found

  21. Great post !! thanks

  22. Hi,
    When i try to login by typing sqlplus on terminal, it asks for username and password. What would be default username and password because while installing it didnt ask for these.
    Thanks in advance.