Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Setting environment variable in Ubuntu 10.4

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

Thanks

 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 367
Eclipse IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi Tim,

I was following the below instructions for Ubuntu 11.10

Hi,
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.
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
pramod, please to not ask the same question in multiple posts.
https://coderanch.com/t/563245/Linux-UNIX/Setting-PATH-Ubuntu#2557280
 
I'm THIS CLOSE to ruling the world! Right after reading this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
    Bookmark Topic Watch Topic
  • New Topic