LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-03-2008, 10:50 AM   #1
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 14.04
Posts: 1,525

Rep: Reputation: 42
$path


Someone please tell me what I'm doing wrong!!
Want to amend PATH.
I enter PATH=$PATH:/usr/lib export PATH in a shell (bash)

echo $PATH gives me the correct PATH
But on restart, it's not there anymore!! Argggh!

I put
PATH=$PATH:/usr/lib export PATH in my .bash_profile in my home directory

Also put PATH=$PATH:/usr/lib export PATH in /etc/profiles.

Where the hell do I have to put it to make it stick?
 
Old 06-03-2008, 11:15 AM   #2
shadowsnipes
Senior Member
 
Registered: Sep 2005
Distribution: Slackware
Posts: 1,442

Rep: Reputation: 71
Set it either in /etc/profile (global) or your ~/.profile (user-specific). If you use the latter you may also want to source your ~/.profile from ~/.bashrc

Code:
if [ -f ~/.profile ]; then
	source ~/.profile
fi
 
Old 06-03-2008, 11:19 AM   #3
cmnorton
Member
 
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Rep: Reputation: 35
Context Needed

If you want your PATH updated only upon logging in, edit ~/.bash_profile (usually Red Hat/rpm-based systems) or ~/.profile for Debian-based systems (at least for Ubuntu).

PATH=$PATH:$HOME/bin

export PATH
unset USERNAME

Please note PATH is exported. PATH is usually defined/updated in the login-only files, rather than .bashrc, which is executed, I believe, every time a shell starts up.

It was not clear from your post if you were adding to PATH on the command line or in a login file as noted above. Unless you absolutely do not want a launched program to have your modified PATH, pre-prending export to the environment variable is a useful thing to do (with any environment variable for that matter).
 
Old 06-03-2008, 11:39 AM   #4
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 14.04
Posts: 1,525

Original Poster
Rep: Reputation: 42
Thanks, but that's what I did. In a bash terminal I put
PATH=$PATH:/usr/lib export PATH in one line, then pressed enter.
I also put exactly that in my home .bash_profile, and to be sure in /etc/profile. On restart, echo $PATH gave me the old PATH again, without /usr/lib That's why I thought I'm doing something wrong here! Am I?
 
Old 06-03-2008, 12:32 PM   #5
shadowsnipes
Senior Member
 
Registered: Sep 2005
Distribution: Slackware
Posts: 1,442

Rep: Reputation: 71
In my ~/.profile I have this for modifying my PATH
Code:
PATH=~/ProgramBuilds:$PATH
I don't need to export it there. Granted, I'm using Slackware, so Debian may be doing things slightly different.

Try just adding
Code:
PATH=$PATH:/usr/lib
to /etc/profile. If it is there you should not need it in any of the files specific to your user.

Was /etc/profile there before this or did you create it? Perhaps Debian look under /etc/profile.d/* instead.

Edit: Just a warning: You probably don't want /usr/lib to be at the end of your PATH, but rather the current directory (".").

Last edited by shadowsnipes; 06-03-2008 at 12:34 PM.
 
Old 06-03-2008, 07:49 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
1. Put the PATH definition on one line and the 'export PATH' on another.
2. do not put your current dir ('.') in your PATH. This is a security hole.
 
Old 06-03-2008, 10:57 PM   #7
shadowsnipes
Senior Member
 
Registered: Sep 2005
Distribution: Slackware
Posts: 1,442

Rep: Reputation: 71
Quote:
Originally Posted by chrism01 View Post
2. do not put your current dir ('.') in your PATH. This is a security hole.
I disagree with this when used in the context of a normal user and when '.' is at the end of the PATH. I agree that it shouldn't be in root's PATH.
 
Old 06-04-2008, 01:06 AM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
1. the damage may be less than root, but its still not fun
2. if you use
su
instead of
su -
you maintain your ORIG env, instead of getting root's ... think about that ...
 
Old 06-04-2008, 01:10 AM   #9
shadowsnipes
Senior Member
 
Registered: Sep 2005
Distribution: Slackware
Posts: 1,442

Rep: Reputation: 71
Quote:
Originally Posted by chrism01 View Post
1. the damage may be less than root, but its still not fun
2. if you use
su
instead of
su -
you maintain your ORIG env, instead of getting root's ... think about that ...
which is why I always use su -

When running as root I often use absolute paths for all my commands anyways...
 
Old 06-04-2008, 01:48 AM   #10
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 14.04
Posts: 1,525

Original Poster
Rep: Reputation: 42
This is my /etc/profile

Quote:
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "`id -u`" -eq 0 ]; then
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
PATH="/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/lib:/usr/include:/usr/include/jasper"
fi

if [ "$PS1" ]; then
if [ "$BASH" ]; then
PS1='\u@\h:\w\$ '
else
if [ "`id -u`" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi

export PATH
PATH=$PATH:/usr/lib:/usr/include:/usr/include/jasper
export PATH


umask 022
How come I'm still not getting /usr/lib in my PATH????
 
Old 06-04-2008, 01:55 AM   #11
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 14.04
Posts: 1,525

Original Poster
Rep: Reputation: 42
/etc/profile is a root file, ie only root can modify it. But I started gedit as su to add /usr/lib and the others. But on starting the computer this morning I still only have $PATH=/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games
Arrrrghh!!
 
Old 06-04-2008, 02:05 AM   #12
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 14.04
Posts: 1,525

Original Poster
Rep: Reputation: 42
Oh, and /etc/profile was there, I just modified it, according to what I read on the net. Wouldn't know how to write a script!
Far as I can see, I'm not doing anything wrong, but it doesn't work!!! Maybe missed a dot or a comma???
 
Old 06-04-2008, 11:41 AM   #13
shadowsnipes
Senior Member
 
Registered: Sep 2005
Distribution: Slackware
Posts: 1,442

Rep: Reputation: 71
I don't think you need the
Code:
PATH=$PATH:/usr/lib:/usr/include:/usr/include/jasper
export PATH
since you already set these extras previously at

Code:
if [ "`id -u`" -eq 0 ]; then
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
PATH="/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/lib:/usr/include:/usr/include/jasper"
fi
Login as a non-root user and
Code:
echo $PATH
Show us what you get.
 
Old 06-04-2008, 12:09 PM   #14
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 14.04
Posts: 1,525

Original Poster
Rep: Reputation: 42
I get the following, but only because this morning I set PATH using PATH=$PATH:/usr/lib, as it didn't have /usr/lib, even though /etc/profile is/was as shown above.

If I do a restart now, I'll probably end up with the old PATH again, can try. Will try and get back to you.
 
Old 06-04-2008, 12:10 PM   #15
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 14.04
Posts: 1,525

Original Poster
Rep: Reputation: 42
OOps, forgot to paste the answer:

peter@vaya:~$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:/usr/lib:/usr/include:/usr/include/jasper
peter@vaya:~$
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
export Path=/usr/java:$Path does not seem to work lumix Linux - Newbie 1 03-19-2007 04:11 PM
Do you add to the path line or make a new path in /etc/profile? M$ISBS Linux - Newbie 2 12-13-2006 03:14 PM
Image Path reference in Linux (Absolute path) javabuddy Linux - General 7 06-05-2006 08:45 AM
script to change unix path to windows path in all files csross Programming 8 04-29-2006 02:05 PM
How to Chnage Python's module search path (sys.path)? lramos85 Linux - Software 1 05-02-2004 07:10 PM


All times are GMT -5. The time now is 05:33 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration