Environmental Variables

Symbolic Name for a set of memory to assign and access the values. It will help to influence the behaviour of an application on the system. To secure our application from the crash we have to give a look into the variables.

By using the variables, we can able to secure the reviling of names, passwords, etc., and if we practice using the variables in the applications are the good habit. For the future development of the system, this will helps a lot of the automation. In future, While going for the provisioning and configuration tools like Ansible this will very much helpful for controlling the configuration and management in a secure way.

Global Variables

~/.bashrc is the easy way to set the global environment variables.

We have to put the entry in that file like this below,

export VARNAME=”my value”

/etc/environment file which will give the global variables it affects all the users.

We have to put the entry in that file like this below,

VARNAME=”my value”

User-specific variables

~/.pam_environment file which will give the user-specific variables.

We have to put the entry in that file like this below,

VARNAME=”my value”

save it and log out & log in again to effective.

How to use the Environment variables?

We have to use the variables which were defined in the variables in the system. Also, we have to use the variables in some specific format based on the file format.

For example, if we want to use the variables in the ruby file, we have to use it in the below format

ENV[‘VARNAME’]

For example, if we want to use the variables in the YML file, we have to use it in the below format

<%= ENV[‘VARNAME’] %>
Categories: Uncategorized