unable to connect to oracle in linux terminal in oracle VM ,TNS listner not connected
You try to connect with / as sysdba, which normally connects locally, and you still get errors related to TNS and listener. Actually, there is a not well-known environment variable, called TWO_TASK, and if you set that, SQL*Plus will automatically try to connect using the value of the variable as a TNS entry.

So if you use TWO_TASK, instead of this:

sqlplus user/password@TNS


you can do this:

export TWO_TASK=TNS
sqlplus user/password


The second method will have the same result as the first, the difference is you do not need to specify the TNS on every connection, you can simply put it in a variable, it may be useful when writing scripts, though I have never used it. Another use-case for it is when you have a CDB and you want to connect to a PDB. You can not connect a PDB directly locally, but you can kind of "emulate" that with TWO_TASK.

So I have the below environment:

[oracle@o61 ~]$ . oraenv
ORACLE_SID = [oracle] ? orcl
The Oracle base has been set to /opt/oracle/base
[oracle@o61 ~]$ lsnrctl status

LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 22-JAN-2016 23:15:23

Copyright (c) 1991, 2014, Oracle.  All rights reserved.

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date                15-JAN-2016 18:17:03
Uptime                    7 days 4 hr. 58 min. 20 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /opt/oracle/grid12102/network/admin/listener.ora
Listener Log File         /opt/oracle/base/diag/tnslsnr/o61/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.6.1)(PORT=1521)))
Services Summary...
Service "orcl" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully


Try to connect with / as sysdba:

[oracle@o61 ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Fri Jan 22 23:15:28 2016

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL&gt; exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
[oracle@o61 ~]$


So far so good, / as sysdba works like a charm. Now let's say I have a TNS entry pointing to another service, that does not exist, for example:

[oracle@o61 ~]$ tnsping mydb

TNS Ping Utility for Linux: Version 12.1.0.2.0 - Production on 22-JAN-2016 23:20:47

Copyright (c) 1997, 2014, Oracle.  All rights reserved.

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.6.1)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = MYDB)))
OK (0 msec)
[oracle@o61 ~]$


tnsping say everything is OK. Well, tnsping does not check the specified service, it only checks the address and port. Still, it is a valid TNS entry anyway. If I try to connect using this TNS entry, it will obviously fail with the infamous 12514 error, as I do not have any service like this, as you could see from my lsnrctl status output. I do not even need to specify a valid username and password to get the error.

[oracle@o61 ~]$ sqlplus user/password@mydb

SQL*Plus: Release 12.1.0.2.0 Production on Fri Jan 22 23:21:50 2016

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

ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor


Enter user-name:


And here comes TWO_TASK, the variable that was meant to make your life easier, but it is also a great feature to play a prank on someone who does not know about it. Even if you connect / as sysdba, SQL*Plus will try to open a remote connection because of it:

[oracle@o61 ~]$ export TWO_TASK=mydb
[oracle@o61 ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Fri Jan 22 23:29:21 2016

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

ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor


Enter user-name: oracle
Enter password:
ERROR:
ORA-12514: TNS:listener does not currently know of service requested in connect
descriptor


Enter user-name:


If you have TWO_TASK set, just unset it, and try to connect again.

[oracle@o61 ~]$ unset TWO_TASK
[oracle@o61 ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Fri Jan 22 23:31:24 2016

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL&gt;