LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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, 09:50 AM   #1
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Rep: Reputation: 73
$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, 10:15 AM   #2
shadowsnipes
Senior Member
 
Registered: Sep 2005
Distribution: Slackware
Posts: 1,443

Rep: Reputation: 73
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, 10: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, 10:39 AM   #4
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Original Poster
Rep: Reputation: 73
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, 11:32 AM   #5
shadowsnipes
Senior Member
 
Registered: Sep 2005
Distribution: Slackware
Posts: 1,443

Rep: Reputation: 73
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 11:34 AM.
 
Old 06-03-2008, 06:49 PM   #6
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,360

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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, 09:57 PM   #7
shadowsnipes
Senior Member
 
Registered: Sep 2005
Distribution: Slackware
Posts: 1,443

Rep: Reputation: 73
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, 12:06 AM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,360

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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, 12:10 AM   #9
shadowsnipes
Senior Member
 
Registered: Sep 2005
Distribution: Slackware
Posts: 1,443

Rep: Reputation: 73
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, 12:48 AM   #10
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Original Poster
Rep: Reputation: 73
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, 12:55 AM   #11
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Original Poster
Rep: Reputation: 73
/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, 01:05 AM   #12
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Original Poster
Rep: Reputation: 73
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, 10:41 AM   #13
shadowsnipes
Senior Member
 
Registered: Sep 2005
Distribution: Slackware
Posts: 1,443

Rep: Reputation: 73
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, 11:09 AM   #14
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Original Poster
Rep: Reputation: 73
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, 11:10 AM   #15
Pedroski
Senior Member
 
Registered: Jan 2002
Location: Nanjing, China
Distribution: Ubuntu 20.04
Posts: 2,116

Original Poster
Rep: Reputation: 73
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



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 03: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 02:14 PM
Image Path reference in Linux (Absolute path) javabuddy Linux - General 7 06-05-2006 07:45 AM
script to change unix path to windows path in all files csross Programming 8 04-29-2006 01:05 PM
How to Chnage Python's module search path (sys.path)? lramos85 Linux - Software 1 05-02-2004 06:10 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:14 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