How to add/set Environment Variable in Ubuntu

There are two ways to set Environment Variables in Ubuntu.

1.    This method will add/set environment variable just for current user session. For example you want to add “/home/imrankabir/.composer/vendor/bin/” to your environment variables.

export PATH=${PATH}:/home/imrankabir/.composer/vendor/bin/

2.    To add/set environment variable permanently, open .profile hidden file in your ubuntu home directory. This will look some thing like this

# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n “$BASH_VERSION” ]; then
# include .bashrc if it exists
if [ -f “$HOME/.bashrc” ]; then
. “$HOME/.bashrc”

# set PATH so it includes user’s private bin if it exists
if [ -d “$HOME/bin” ] ; then

Now add following line to this file (may be before “# if running bash” commented line) and save the file.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s