linux - [Solved-2 Solutions] How to delete (unset) an exported environment variable ? - ubuntu - red hat - debian - linux server - linux pc



Linux - Problem :

How to delete (unset) an exported environment variable ?

Linux - Solution 1:

unset GNUPLOT_DRIVER_DIR
click below button to copy the code. By - Linux tutorial - team

Linux - Solution 2:

Creating and deleting an environment variable in bash:

Test if the DUALCASE variable exists:

el@apollo:~$ env | grep DUALCASE
el@apollo:~$ 
click below button to copy the code. By - Linux tutorial - team

It does not, so create the variable and export it:

el@apollo:~$ DUALCASE=1
el@apollo:~$ export DUALCASE
click below button to copy the code. By - Linux tutorial - team

Check if it is there:

el@apollo:~$ env | grep DUALCASE
DUALCASE=1
click below button to copy the code. By - Linux tutorial - team
el@apollo:~$ unset DUALCASE
click below button to copy the code. By - Linux tutorial - team

Check if it's still there:

el@apollo:~$ env | grep DUALCASE
el@apollo:~$ 
click below button to copy the code. By - Linux tutorial - team

The DUALCASE exported environment variable is deleted.

Extra commands to help clear your local and environment variables:

Unset all local variables back to default on login:

el@apollo:~$ CAN="wikitechy"
el@apollo:~$ set | grep CAN
CAN='wikitechy'
el@apollo:~$ env | grep CAN
el@apollo:~$
el@apollo:~$ exec bash
el@apollo:~$ set | grep CAN
el@apollo:~$ env | grep CAN
el@apollo:~$
click below button to copy the code. By - Linux tutorial - team

exec bash command cleared all the local variables but not environment variables.

Unset all environment variables back to default on login:

el@apollo:~$ export DOGE="welcome to wikitechy"
el@apollo:~$ env | grep DOGE
DOGE=welcome to wikitechy
el@apollo:~$ env -i bash
el@apollo:~$ env | grep DOGE
el@apollo:~$
click below button to copy the code. By - Linux tutorial - team

env -i bash command cleared all the environment variables to default on login.


Related Searches to - linux - linux tutorial - How to delete (unset) an exported environment variable ?