Bookmark Topic Watch Topic
  • New Topic

Setting environment variable in Ubuntu 10.4  RSS feed

Nikes Shah
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi All,

I am new to Linux flavor systems.

Can anyone guide in which file we can set environment variable?
Is there any UI available like windows for environment variable setup?

I have an ant script which expects a path defined in environment variable.


Tim Holloway
Saloon Keeper
Posts: 18799
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Report post to moderator
There are many - perhaps too many - places to set environment variables. Environment variables are part of the environment component of the command shell, and Linux has probably half a dozen major shells to choose from, with bash being the most popular, but also csh, ksh, zsh, and others being used as well.

The closes thing to the "system" environment in Windows is probably /etc/profile, which is a reference for all the major shells. Each shell generally maintains one or more profiles unique to that shell - for example ".bash_profile", which is a file in the user's home directory used to setup the environment for the bash shell. User-specific profiles are are "hidden" files, and the user-specific version of /etc/profile is "~/.profile", where "~" is the shorthand for the user's home directory as implemented in most popular shells.

When a shell or the desktop spawns a sub-shell, the spawning process has the option to propagate a copy of the parent shell to the sub-shell or to create a new, empty environment, Likewise, the spawning shell can request that the user's login script be executed or ignored, and the login script is what sets the user's initial environment at login.

All of this can get pretty complicated, but for basic purposes, you probably want an entry in the ~/.profile file such as this:

Depending on the shell, you may need to do the export as a separate command after you set the value. You must export the environment variable or it will only be in effect for the current shell.
pramod talekar
Ranch Hand
Posts: 367
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi Tim,

I was following the below instructions for Ubuntu 11.10

I was following these instructions :

The ~/.bash_profile ($HOME/.bash_profile) or ~/.prfile file is executed when you login using console or remotely using ssh. Type the following command to edit ~/.bash_profile file, enter:
$ vi ~/.bash_proflle

Append the $PATH settings, enter:
export PATH=${PATH}:${HOME}/bin

Save and close the file.

I entered the first command vi~/.bash_profile on the terminal and pressed ENTER.
The terminal now shows a blank screen with ~ at the beginning of every line & ~/.bash_profile [New File] at the bottom.
Now if i try to write anything then nothing appears in the terminal while the bottom line shows 'Nothing to register'.

Is there a way to open such file in Notepad and then append the line ?

Please advise.
Peter Johnson
Posts: 5856
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
pramod, please to not ask the same question in multiple posts.
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!