Contents
How do I pass an environment variable in Bash?
The easiest way to set environment variables in Bash is to use the “export” keyword followed by the variable name, an equal sign and the value to be assigned to the environment variable.
How do you initialize an environment variable in Linux?
To make an environment persistent for a user’s environment, we export the variable from the user’s profile script.
- Open the current user’s profile into a text editor. vi ~/.bash_profile.
- Add the export command for every environment variable you want to persist. export JAVA_HOME=/opt/openjdk11.
- Save your changes.
What is LD_LIBRARY_PATH variable?
The LD_LIBRARY_PATH environment variable tells Linux applications, such as the JVM, where to find shared libraries when they are located in a different directory from the directory that is specified in the header section of the program.
How to set the environment variable LD _ LIBRARY _ PATH?
export LD_LIBRARY_PATH=. All users have the environment variable added. You could try adding a custom script, say myenv_vars.sh in /etc/profile.d. Add this to the empty file, and save it. Logout and login, LD_LIBRARY_PATH will have been set permanently.
Where do I set LD LIBRARY PATH in Ubuntu?
CORRECTION: I should take my own advice and actually read the documentation. It says that this does not apply to LD_LIBRARY_PATH: Since Ubuntu 9.04 Jaunty Jackalope, LD_LIBRARY_PATH cannot be set in $HOME/.profile, /etc/profile, nor /etc/environment files. You must use /etc/ld.so.conf.d/ .conf configuration files.*
Where do I put the bash profile file?
So user1824407’s answer is spot on. Read more here. The file .bash_profile is only executed by login shells. You may need to put it in ~/.bashrc, or simply logout and login again. For some reason no one has mentioned the fact that the bashrc needs to be re-sourced after editing.