LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-16-2001, 11:27 PM   #1
rdaves@earthlink.net
Member
 
Registered: May 2001
Location: Full-time traveler I live where I am.
Distribution: I use Red Hat V 7.1
Posts: 297

Rep: Reputation: 30

How do I change the path that Linux is using? -
The "how to" that I am following is in the June, 2001 Linux Magazine's "newbies" column. In this column, the author suggests modifying the .bash_profile, but doesn't specify which one to alter.

I have experimented with changing the three files I have found, however none of the changes "take":
/etc/skel/.bash_profile
/home/ronsan/.bash_profile
/root/.bash_profile
 
Old 06-17-2001, 09:38 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
if it's adding to the global path, you've got to look in /etc/profile, if it's a userpath add it to ~/.bash_profile in the path statement. After each change you've got to execute to make it stick: ". ./etc/profile" or ". ~/.bash_profile".

*The source in skel is added to their new home when users are added. Keep it clean.

*I would strongly advice you to NOT add custom paths to the /root/.bash_profile that users can write in, it is considered bad for your boxes health.
 
Old 06-17-2001, 01:59 PM   #3
rdaves@earthlink.net
Member
 
Registered: May 2001
Location: Full-time traveler I live where I am.
Distribution: I use Red Hat V 7.1
Posts: 297

Original Poster
Rep: Reputation: 30
Don't understand, yet

I'm not sure I understand, yet, how to change the PATH environment variable. I have added to the PATH section of my /etc/profile file and also to my /home/.bash_profile. However, when I reboot, nothing changes. I am running Red Hat v7.0 upgraded to the kernel 2.4. Is some other file than those I have mentioned being used by the system to determine the path?
 
Old 06-17-2001, 02:15 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Ok, but you really don't have to reboot to make it work :-]

Say my /etc/profile contains:
PATH=/bin:/sbin:/usr/sbin:/opt
export PATH

Now I want to add a specific path as required by say Netscape, there are two ways.
1. I can add it to the already defined PATH statement if it is just like finding an application in a path, or 2. I can add a separate path if the application requires it to be a known environment variable.

1:
Adding the path my /etc/profile now sez:
PATH=/bin:/sbin:/usr/sbin:/opt:/usr/lib/netscape
export PATH

or

2:
Adding the path my /etc/profile now sez:
PATH=/bin:/sbin:/usr/sbin:/opt
MOZILLA_HOME=/usr/lib/netscape
export PATH MOZILLA_HOME

Execute ". /etc/profile" after changing the path *should* make it work. If it still doesn't please post why you need it, that many be helpfull + errors, if any.
 
Old 06-26-2001, 04:36 PM   #5
rdaves@earthlink.net
Member
 
Registered: May 2001
Location: Full-time traveler I live where I am.
Distribution: I use Red Hat V 7.1
Posts: 297

Original Poster
Rep: Reputation: 30
Just doesn't work for me

There is something I don't understand about adding to the PATH environment variable string:

Here's my /etc/profile:
if ! echo $PATH | /bin/grep -q "/usr/X11R6/bin" ; then PATH="$PATH:/USR/X11R6/bin"
fi
(export PATH, etc, follows)


I have added the following:
PATH=$PATH:/sbin

Then, after typing

# /etc/profile

(export PATH, etc, follows)

I type

# env

No change

I have followed an article in Linux magazine, and no matter what I try, the PATH does not change. I have followed the advice in this post by Unspawn (recommendation 1, only. Do not understand #2)
and nothing changes.

I would like to have /sbin/ in my PATH, because I use files that reside there often, and would rather not type /sbin/filename every time I need to use a file therein. I am also curious as to why this does not work for me
 
Old 06-26-2001, 06:08 PM   #6
linuxcool
LQ Addict
 
Registered: Jun 2001
Posts: 1,183

Rep: Reputation: 47
I'm not certain if I understand exactly what you want, but here goes.

I think this is what you want:


if ! echo $PATH | /bin/grep -q "/usr/X11R6/bin" ; then
PATH=$PATH:/usr/X11R6/bin
fi
PATH=$PATH:/sbin
export PATH



Then type in: . /etc/profile

Now note in the second line of /etc/profile that I deleted the double quotes and I changed USR to usr. I also placed the PATH=$PATH:/sbin before the export line. When you type in the line . /etc/profile , don't forget the period at the begining of the line and the period is followed by a space. This space is important. If it is not there, bash will create a subshell to execute the command and when the subshell is done, all the changes that were made will disappear with it. I hope this works. I've never tried this before. Good luck.
 
Old 06-27-2001, 01:33 AM   #7
rdaves@earthlink.net
Member
 
Registered: May 2001
Location: Full-time traveler I live where I am.
Distribution: I use Red Hat V 7.1
Posts: 297

Original Poster
Rep: Reputation: 30
AHA!
The suggestion by linuxcool about about putting the space in the command '. /etc/profile' solved the problem of why the path was never changing. I was not typing the command correcly.

I was also confused by the fact that the PATH changes depending on whether a non-root user or root user is logged on.

Adding to the confusion is the fact that the PATH differs if I login as Root on the login screen or su from a terminal screen.

Some day I will understand this.
 
Old 06-27-2001, 05:21 PM   #8
linuxcool
LQ Addict
 
Registered: Jun 2001
Posts: 1,183

Rep: Reputation: 47
Glad to help.

Also, about logging in from a terminal screen or su to root. When you login from a terminal screen you'll get root's path. When su to root in a user's terminal, you'll get the user's path unless you enter the command su - . The hyphen will ensure that the user's path is changed to root's path. This means that you won't get the ' command not found error ' when trying to execute commands that only root can.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Image Path reference in Linux (Absolute path) javabuddy Linux - General 7 06-05-2006 07:45 AM
Apache path and kde path questions darkraider Debian 1 11-12-2005 05:07 AM
Linux programs(commands) path sureshkellemane Linux - Newbie 6 03-29-2005 02:15 AM
How to Chnage Python's module search path (sys.path)? lramos85 Linux - Software 1 05-02-2004 06:10 PM
Executing commands without using the full path.. LinuxBAH *BSD 2 12-02-2003 07:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration