DBA Hub

📋Steps in this guide1/4

Environment Variables in Linux

Please Note

oracle configurationintermediate
by OracleDba
14 views
1

Overview

Please Note - Always use UPPERCASE for variable names - Put value under ” “(double quote) if it contains spaces or single quotes. - Put value under ‘ ‘ if it contains double quotes. - You have to use $ when you want to call a variable’s stored value. When you set environment variables using linux export command, these variables scope is limited to only session level. once You close the terminal and login again, the variables are cleared from the system.

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
syntax : export =

e.g.
export MY_WEBSITE=learnomate.org
export ARTICLE="Environment Variables in Linux"
export dba ='Learnomate is "BEST" Training institute.'

e.g.

echo "Current website is $MY_WEBSITE"
echo "You are reading $ARTICLE"

env
To filter all the variables listed by env command
env | grep MY                --> prints all vars containing MY
env | grep HOME              --> prints all vars containing HOME
2

Section 2

To make the variables permanent so that they are available when you login again, you must set the variables inside Bash profile. vi .bash_profile                      –> user’s home location export MY_WEBSITE=learnomate.org export ARTICLE=”Environment Variables in Linux” You need to source (or load) the .bash profile for Linux to load new environment variables source .bash_profile
3

Section 3

echo $MY_WEBSITE echo $ARTICLE The variables set under .bash profile are only available to the particular user. For example, if Oracle user sets environment variables under its own . bash profile , then its accessible only to Oracle user. To define system wide environment variables, add variables to /etc/environment file. As root user:
4

Section 4

vi /etc/environment export SYS_VAR=”System Wide Variable” Logout and login. Now SYS_VAR is available to all the users on Linux server!

Comments (0)

Please to add comments

No comments yet. Be the first to comment!