How to Set Environment Variable in Ubuntu

I need to set LD_LIBRARY_LIB path into Ubuntu Environment Variable, but i cant find ~/.bash_profile in Ubuntu? I issue following command to search through whole file system

sudo find / -name .bash_profile

It return me nothing, hmm… it seem Ubuntu do not have ~/.bash_profile like other Linux distribution version. It left me no choice but set environment variable in /etc/profile.

Here i provide two ways to set environment variable in /etc/profile

1) su to root and Issue following command

  echo "export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/postgresql/8.3/lib;" >> /etc/profile

2) VI to edit /etc/profile
Append “export LD_LIBRARY_PATH=/usr/local/lib:/usr/lib/postgresql/8.3/lib;” to end of the /etc/profile content (after what unmask xxx).

After modified /etc/profile, hit CTRL+ALT+Backspace to restart x windows to take effect.

P.S user also can append export into .bashrc to set environment variable in linux

cd ~
vim .bashrc

About the Author

author image
mkyong
Founder of Mkyong.com, love Java and open source stuff. Follow him on Twitter. If you like my tutorials, consider make a donation to these charities.

Comments

avatar
2 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
2 Comment authors
KRnatarajan Recent comment authors
newest oldest most voted
KR
Guest
KR

/etc/environment – This file is specifically meant for system-wide environment variable settings. It is not a script file, but rather consists of assignment expressions, one per line. Specifically, this file stores the system-wide locale and path settings.

natarajan
Guest
natarajan

Hi Dude,

Nice Info!! Keep it up with good work…

Thanks,
Natarajan