SUN_Solaris

I had written an article previously on how to set the environment variables in Linux/Unix system. You may want to have a look it here. Let’s see how we can delete the variables in the SUN Solaris system. The “env” command will display all the variables in the current user.

SUNOS% env
HOME=/opt/oracle
PATH=/opt/JDK/j2sdk1.4.1_02/bin:/bin:/usr/bin:/usr/ucb:/usr/ccs/bin:/etc:/usr/local/bin:/opt/usr/local/bin:/usr/dt/bin:/opt/iplanet/servers:/opt/oracle/oracle9/bin:/opt/oracle/jre/1.1.8/bin:/opt/oracle/web/bin:/opt/oracle/mms_run/bin:/opt/oracle/mms_run/shell:.
LOGNAME=oracle
HZ=100
TZ=:GMT+5
TERM=vt100
SHELL=/usr/bin/csh
PWD=/opt/oracle
USER=oracle
ORACLE_BASE=/opt/oracle
ORACLE_HOME=/opt/oracle/oracle9
ORACLE_SID=oracle9
LD_LIBRARY_PATH=/opt/oracle/oracle9/lib
TNS_ADMIN=/opt/oracle/oracle9/network/admin
ORA_NLS33=/opt/oracle/oracle9/ocommon/nls/admin/data
DISPLAY=192.168.3.13:1.0
NLS_LANG=American_America.US7ASCII
DISPLAY=192.168.3.211:1.0=

As we can see, there are two DISPLAY variables in the system. Lets first delete both of these variables as shown below:

SUNOS% unsetenv DISPLAY
SUNOS%
SUNOS% env
HOME=/opt/oracle
PATH=/opt/JDK/j2sdk1.4.1_02/bin:/bin:/usr/bin:/usr/ucb:/usr/ccs/bin:/etc:/usr/local/bin:/opt/usr/local/bin:/usr/dt/bin:/opt/iplanet/servers:/opt/oracle/oracle9/bin:/opt/oracle/jre/1.1.8/bin:/opt/oracle/web/bin:/opt/oracle/mms_run/bin:/opt/oracle/mms_run/shell:.
LOGNAME=oracle
HZ=100
TZ=:GMT+5
TERM=vt100
SHELL=/usr/bin/csh
PWD=/opt/oracle
USER=oracle
ORACLE_BASE=/opt/oracle
ORACLE_HOME=/opt/oracle/oracle9
ORACLE_SID=oracle9
LD_LIBRARY_PATH=/opt/oracle/oracle9/lib
TNS_ADMIN=/opt/oracle/oracle9/network/admin
ORA_NLS33=/opt/oracle/oracle9/ocommon/nls/admin/data
NLS_LANG=American_America.US7ASCII
DISPLAY=192.168.1.211:1.0=

SUNOS%

As we can see, by using the unsetenv command, we have deleted the first variable but the second variable same as the first one only with a different values is still on the list. This shows that this command checks the environment variables list in a linear fashion and delete the first one as we run the command one time. Lets see what happens when we run the command the second time.

mms1% unsetenv DISPLAY
mms1%
mms1% env
HOME=/opt/oracle
PATH=/opt/JDK/j2sdk1.4.1_02/bin:/bin:/usr/bin:/usr/ucb:/usr/ccs/bin:/etc:/usr/local/bin:/opt/usr/local/bin:/usr/dt/bin:/opt/iplanet/servers:/opt/oracle/oracle9/bin:/opt/oracle/jre/1.1.8/bin:/opt/oracle/web/bin:/opt/oracle/mms_run/bin:/opt/oracle/mms_run/shell:.
LOGNAME=oracle
HZ=100
TZ=:GMT+5
TERM=vt100
SHELL=/usr/bin/csh
PWD=/opt/oracle
USER=oracle
ORACLE_BASE=/opt/oracle
ORACLE_HOME=/opt/oracle/oracle9
ORACLE_SID=oracle9
LD_LIBRARY_PATH=/opt/oracle/oracle9/lib
TNS_ADMIN=/opt/oracle/oracle9/network/admin
ORA_NLS33=/opt/oracle/oracle9/ocommon/nls/admin/data
NLS_LANG=American_America.US7ASCII
mms1%

So, both the variables have been removed. In this way, we can delete any variable in the list.

Adnan Khurshid

Adnan Khurshid, the author of this article, has been working in a telecommunication sector since 2007. He has worked there as a VAS (Value Added Services) engineer and has excelled remarkably in the field. Working in this field has been his passion and he has always made efforts to keep himself up to date. Find more about him on LinkedIn

More Posts

Tags: , , ,

1 Comment on How to delete environment variables in SUN Solaris

  1. artificial insemination cost says:

    Hi there, You’ve done an incredible job.I will definitely digg it and personally suggest to my friends.I am sure they will be benefited from this site

Leave a Reply