The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

If you can read me, I'm broken!

Views: 6,725     Votes:  4     ✅ Solution
Tags: 18.04   java   environment-variables  
Link: 🔍 See Original Answer on Ask Ubuntu ⧉ 🔗

URL: https://askubuntu.com/q/1131572
Title: Can't remove environmental variable in Ubuntu 18.04
ID: /2019/04/06/Can_t-remove-environmental-variable-in-Ubuntu-18.04
Created: April 6, 2019    Edited:  April 6, 2019
Upload: April 8, 2024    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false


$JAVA_HOME will already have a definition on many systems without explicitly declaring it in /etc/environment:

$ echo $JAVA_HOME
/usr/lib/jvm/java-8-oracle

That said, the unset command will eliminate a variable. From: Unix / Linux - Using Shell Variables

##Unsetting Variables

Unsetting or deleting a variable directs the shell to remove the
variable from the list of variables that it tracks. Once you unset a
variable, you cannot access the stored value in the variable.

Following is the syntax to unset a defined variable using the unset
command −

unset variable_name  

The above command unsets the value of a defined variable. Here is a
simple example that demonstrates how the command works −

#!/bin/sh  

NAME="Zara Ali"  
unset NAME  
echo $NAME  

In our case we can use:

$ echo $JAVA_HOME
/usr/lib/jvm/java-8-oracle
───────────────────────────────────────────────────────────────────────────────────────────
$ unset JAVA_HOME
───────────────────────────────────────────────────────────────────────────────────────────
$ echo $JAVA_HOME

───────────────────────────────────────────────────────────────────────────────────────────
$ 
⇧ Prevent sleep/suspend when not logged in to a specific account How to disable sleep / suspend / hibernate HP keyboard buttons for Ubuntu 18.04?  ⇩