Image may be NSFW.
Clik here to view.
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.