Advertisement

02.24.2004 at 01:51AM PST, ID: 20895782
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

How to set environment variables
Tags: linux, environment, set, variable
How do you set the PATH, JAVA_HOME or CLASSPATH in Redhat Linux?

I want to know how to set it such that when the OS is booted up, these variables are set. In Windows, this is done in the Control Panel -> System -> Advance -> Environment Variables.

I also want to know how you override the default variables in a particular shell. In Windows, we can do SET PATH=%PATH%;c:\newpath to override the default PATH.
Start your free trial to view this solution
Question Stats
Zone: OS
Question Asked By: yongsing
Solution Provided By: majorwoo
Participating Experts: 5
Solution Grade: A
Views: 975
Translate:
Loading Advertisement...
02.24.2004 at 02:24AM PST, ID: 10439635

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.24.2004 at 02:27AM PST, ID: 10439654

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.24.2004 at 02:29AM PST, ID: 10439661

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.24.2004 at 08:03AM PST, ID: 10441949

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.24.2004 at 05:23PM PST, ID: 10446773

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.24.2004 at 06:06PM PST, ID: 10446991

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.24.2004 at 07:09PM PST, ID: 10447344

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.24.2004 at 07:37PM PST, ID: 10447439

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.24.2004 at 08:09PM PST, ID: 10447573

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.24.2004 at 08:28PM PST, ID: 10447639

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.24.2004 at 11:57PM PST, ID: 10448410

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.25.2004 at 06:54AM PST, ID: 10450833

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.25.2004 at 07:54AM PST, ID: 10451429

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.26.2004 at 12:52AM PST, ID: 10458270

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.26.2004 at 04:56AM PST, ID: 10459685

Rank: Master

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.27.2004 at 12:26AM PST, ID: 10467428

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
06.25.2004 at 11:41AM PDT, ID: 11401329

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
02.24.2004 at 02:24AM PST, ID: 10439635

Rank: Master

if you are using bash
export JAVA_HOME="/usr/java/jdk1.3.1_01"

and if you are using tcsh
setenv JAVA_HOME /usr/java/jdk1.3.1_01

to Add a extra path do this in bash
export PATH=$PATH:/hejsan
Assisted Solution
 
02.24.2004 at 02:27AM PST, ID: 10439654

Rank: Master

sry didnt read the the middle questione

put that in /etc/bashrc if bash

and /etc/csh.login for tcsh

this applays to all users if you just want i to your self put only in

%HOME%/.bashrc or
%HOME%/.tcshrc
 
02.24.2004 at 02:29AM PST, ID: 10439661

Rank: Master

type
env
to see what your env settings are and what shell you are using under SHELL

/Rob
 
02.24.2004 at 08:03AM PST, ID: 10441949

Rank: Master

da99rmd is right, another way is if you are setting this up for multiple users it can set in /etc/profile and it will be set for all system users at bootup
 
02.24.2004 at 05:23PM PST, ID: 10446773
I am using bash. Should I edit /etc/bashrc or etc/profile?

How do I add the settings in the file? This is how /etc/bashrc looks like:


# /etc/bashrc

# System wide functions and aliases
# Environment stuff goes in /etc/profile

# by default, we want this to get set.
# Even for non-interactive, non-login shells.
if [ "`id -gn`" = "`id -un`" -a `id -u` -gt 99 ]; then
      umask 002
else
      umask 022
fi

# are we an interactive shell?
if [ "$PS1" ]; then
    if [ -x /usr/bin/tput ]; then
      if [ "x`tput kbs`" != "x" ]; then # We can't do this with "dumb" terminal
        stty erase `tput kbs`
      elif [ -x /usr/bin/wc ]; then
        if [ "`tput kbs|wc -c `" -gt 0 ]; then # We can't do this with "dumb" terminal
          stty erase `tput kbs`
        fi
      fi
    fi
    case $TERM in
      xterm*)
            if [ -e /etc/sysconfig/bash-prompt-xterm ]; then
                  PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm
            else
                PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"'
            fi
            ;;
      screen)
            if [ -e /etc/sysconfig/bash-prompt-screen ]; then
                  PROMPT_COMMAND=/etc/sysconfig/bash-prompt-screen
            else
            PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\033\\"'
            fi
            ;;
      *)
            [ -e /etc/sysconfig/bash-prompt-default ] && PROMPT_COMMAND=/etc/sysconfig/bash-prompt-default
          ;;
    esac
    # Turn on checkwinsize
    shopt -s checkwinsize
    [ "$PS1" = "\\s-\\v\\\$ " ] && PS1="[\u@\h \W]\\$ "
   
    if [ "x$SHLVL" != "x1" ]; then # We're not a login shell
        for i in /etc/profile.d/*.sh; do
          if [ -r "$i" ]; then
              . $i
          fi
      done
    fi
fi
# vim:ts=4:sw=4
 
02.24.2004 at 06:06PM PST, ID: 10446991

Rank: Master

The global /etc/profile and your own local  ~/.bash_profile are read when the shell is invoked as an interactive login shell, for example when you open a remote terminal session to someone else's machine, or when you log into your own machine without X Windows running, or when you hit ctrl-alt-F1 from X Windows to start a virtual terminal session.

The global /etc/bashrc (if it exists) and your own local  ~/.bashrc is read when the shell is invoked as an interactive non-login shell, for example when you open up a terminal window in Gnome or KDE.

So it sounds like you'll be wanting it in your /etc/bashrc if you want to set it for all users, or in your ~/.bashrc if it's just for you.

Assisted Solution
 
02.24.2004 at 07:09PM PST, ID: 10447344
This sounds really confusing. I just need to know the Linux's equivalent to Windows setting via Control Panel -> System -> Advance -> Environment Variables.

It would be good if you can show me what to add to the relevant file.
 
02.24.2004 at 07:37PM PST, ID: 10447439

Rank: Master

edit your ~/.bashrc with your favourite editor
add those export commands to the end of the file, that da99rmd told you about up in his first post.  
save, exit the editor.  
log out, log back in.

 
02.24.2004 at 08:09PM PST, ID: 10447573

Rank: Master

/etc/profile
would be more akin to env variables in windows (as /etc/profile is independent of shell choices)

to set something in /etc/profile you simply do:

VARIABLE_NAME=VALUE_YOU_WANT_IT_TO_BE

and then add to the export line the variable name giving you something like:

export PATH USER VARIABLE_NAME

if you don't want to reboot (or log in/out) you can then type:
source /etc/profile

for all practical purposes though, for a one user system ~/.bashrc is the same

Accepted Solution
 
02.24.2004 at 08:28PM PST, ID: 10447639

Rank: Master

majorwoo all show you the way, only that you have to login/get into a console mode (dos mode like) and use your editor to edit the file /etc/profile as majorwoo suggested.

and you have to login as root (the super user of linux/unix)

 
02.24.2004 at 11:57PM PST, ID: 10448410

Rank: Master

Im not realy in to windows but if the settings you are talking about in control pannel apply to all users or you want it to work that way put it in

/etc/bashrc

And if you just want the settings to the user you are using put it in your home directory in the file

.bashrc

/Rob
 
02.25.2004 at 06:54AM PST, ID: 10450833

Rank: Master

In Windows you open up a graphical dialogue, & click the "environment variables" button.  In there you can set variables for all users (known in MS Windows as "system variables") or just for the currently logged-in user ("user variables" in Windows)

There's only one right way to do it in MS Windows. It doesn't always work, but at least you know you tried the right thing. :-)

With Linux you gain the freedom to do it different ways, but at the price of reading lots of turgid manuals, and learning the several ways to configure things.  It might seem like a pain at first to learn this stuff, yongsing, but it's definitely worth it in the end.

 
02.25.2004 at 07:54AM PST, ID: 10451429

Rank: Master

da99rmd,

/etc/bashrc woud apply to all users using the bash shell (which is indeed the default for many linux systems) however if a user is using a different shell /etc/bashrc would be ignored.  Take a look at your /etc/passwd file, you will see  something like:
guest:x:509:500::/home/guest:/bin/bash
indicating the user guest, uses the bash shell.  If this here changed (if the user used a different shell such as /bin/csh, or alternatively if they launched their own new shell once logging in anythign entered in /etc/bashrc would not be read by that shell)

/etc/profile on the other hand is read by all user shells regardless of what the user has set
 
02.26.2004 at 12:52AM PST, ID: 10458270

Rank: Master

jdfox, but then you end up lerning somthing on the way when you are using linux :)

majorwoo, thats correct but most users dont chsh :/
 
02.26.2004 at 04:56AM PST, ID: 10459685

Rank: Master

for sure, I'm just arguing principle now.  It "is" closer to the windows way ;-)
 
02.27.2004 at 12:26AM PST, ID: 10467428
Thanks guys!
 
06.25.2004 at 11:41AM PDT, ID: 11401329
Modify the file /etc/csh.login

something like this:

setenv PATH ".:/bin:/usr/bin:/usr/local/bin"   <--note the . which sets up local dir in path

setenv JAVA_HOME "/opt/myjava"


to edit that path later use the following:

setenv PATH ".:${PATH}:/somewhere/new"
 
 
20080236-EE-VQP-29