RHEL7: How to set up an environment variable.

Share this link

Presentation

Let’s suppose you need to assign “/usr/lib/jvm/java-1.8.0” to the JAVA_HOME environment variable.

You can need to set up an environment variable in at least three different cases:

  • for a simple user (we will take the centos user as an exemple),
  • for the root user,
  • for all the users (root included).

Simple User Configuration

Connect as the centos user (or any user that you chose except root). By default you should be at the root of the home directory. If it’s not the case, type cd.

Edit the .bash_profile file and paste the following line at the end of the file:

export JAVA_HOME=”/usr/lib/jvm/java-1.8.0″

Root User Configuration

Connect as the root user. By default you should be under /root. If it’s not the case, type cd.

Edit the .bash_profile file and paste the following line at the end of the file:

export JAVA_HOME=”/usr/lib/jvm/java-1.8.0″

All Users Configuration

Connect as the root user. Create a file with any name finishing by .sh in the /etc/profile.d directory (here we will use javaenv.sh).

Paste the following line into the file:

export JAVA_HOME=”/usr/lib/jvm/java-1.8.0″

Set the correct access rights on the file:

# chmod 0755 /etc/profile.d/javaenv.sh

Note: This is required otherwise only the root user would get the environment variable assigned.

Source: StackExchange.com

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

RHCSA7: Task of the day

Allowed time: 5 minutes.
Create two users "tom" and "engine". "tom" has the UID/GID 3000 and "engine" the UID/GID 4000. "engine" doesn't have an interactive shell.

RHCE7: Task of the day

Allowed time: 3 minutes.
Configure your machine to be a router.

Follow me on Twitter

Poll for favorite RHEL 7 book

What is your favorite RHEL 7 book to prepare RHCSA & RHCE exams?

View Results

Loading ... Loading ...

Poll for most difficult RHCSA 7 topic

What do you think is the most difficult RHCSA 7 topic?

View Results

Loading ... Loading ...

Poll for most difficult RHCE 7 topic

What do you think is the most difficult RHCE 7 topic?

View Results

Loading ... Loading ...