Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to set environment variable in RED HAT (as set path command in Windows)  RSS feed

 
Henry Kaldera
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to set the environment variable in Red Hat Linux ? as set path command in Windows ?
 
M Beck
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if you're using a bourne-derived shell such as bash (and you almost certainly are), then the "export" built-in command does what you want. e.g.,

of course, that will only set the environment variable for the duration of that session. to change it so as to have the cahnge survive a logout, you'll need to edit your ~/.bashrc file.
 
Mahesh Rana
Ranch Hand
Posts: 139
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using ksh,
Edit ~/.profile to add any evn. variable.
e.g.
MY_LIBS=/home/my/libs
export MY_LIBS.

If you are using bash,
Edit ~/.bash_profile to add the env.

To find out what shell you are usin, do
echo $SHELL or
cat /etc/passwd | grep `id -un`
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!