LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 01-03-2006, 07:37 PM   #1
kinetik
Member
 
Registered: Dec 2005
Location: The most beautiful city in the world.
Distribution: Mostly RedHat. Also Suse, Ubuntu, PHLAK etc.
Posts: 149

Rep: Reputation: 15
Howto set PATH globally?


Hi there


I'm sorry if I'm asking a question repeated a billion times, but I can't seem to figure out how to set a path for any and all users by modifying as few files as possible...

What I do know: To edit a single user's bash profile, I need to edit .bash_profile in whichever user I want to edit's Home directory, right?

What I don't know: How can I edit the bash profile globally? Where is the file located? What do I need to add in the file itself and where?


Let's say I want to add /sbin/ as a path in a bash profile, where do I need to go and what do I need to do?


Thanks all for any help!



Something else I'd like to know: How can I make it that all users don't need to add ./ when executing commands in bash?


I'm using RHEL3 btw...
 
Old 01-03-2006, 07:46 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Squeeze
Posts: 5,784

Rep: Reputation: 311Reputation: 311Reputation: 311Reputation: 311
As root, edit /etc/profile. All entries there apply to all users.

However, when you update/upgrade, that file may be overwritten and you could loose those global configs. So, make a backup copy (same basic name; just different in some way) so that you can cut and paste into any revised version of /etc/profile after update/upgrade.
 
Old 01-03-2006, 09:11 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
Quote:
Originally Posted by kinetik
Hi there

Something else I'd like to know: How can I make it that all users don't need to add ./ when executing commands in bash?

I'm using RHEL3 btw...
./foo means execute foo in the current directory--ie don't look in PATH to see where the executables are.

The only way that you would not need ./ is if the executable file in in a directory listed in PATH
 
Old 01-04-2006, 12:00 AM   #4
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Quote:
Originally Posted by pixellany
The only way that you would not need ./ is if the executable file in in a directory listed in PATH
Not quite true as shown in the fragment below of the /etc/profile of a standard Slackware 10 installation
Code:
# For non-root users, add the current directory to the search path:
if [ ! "`id -u`" = "0" ]; then
 PATH="$PATH:."
fi
Please note that the current directory is only added for non-root users for security reasons.
 
Old 01-04-2006, 11:37 AM   #5
kinetik
Member
 
Registered: Dec 2005
Location: The most beautiful city in the world.
Distribution: Mostly RedHat. Also Suse, Ubuntu, PHLAK etc.
Posts: 149

Original Poster
Rep: Reputation: 15
Thanks for all the help so far everyone.

Just one more thing: Let's say I want to add /home/apps/utils/ as a PATH, what should I type in the profile file and where exactly? I'm not expecting to be spoon-fed here, so if you perhaps even just have a link with info on these things that should do fine.

I'm still lost on the ./ thing though... Do I have this right -> Is typing in ./ before a command the same as typing in sh?
 
Old 01-04-2006, 11:41 AM   #6
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,401

Rep: Reputation: 1119Reputation: 1119Reputation: 1119Reputation: 1119Reputation: 1119Reputation: 1119Reputation: 1119Reputation: 1119Reputation: 1119
It's very useful to read info bash.

There's a reason why the seemingly-arcane ./ syntax is used... it is so that someone cannot sneak a file into your home-directory whose name matches that of a command that you commonly use, and thereby cause you to execute code that you were not aware of. If you want to execute a file in your local directory, this pair of keystrokes explicitly tells Bash to do so; otherwise Bash will assume that "such-and-so command" should be executed the same way for every user, no matter what may be found in their home-directory.

DOS didn't do that; neither did RSTS-E or VAX/VMS or CP/M from which many of the MS-DOS ideas came. I think that what Bash is doing is better, having done my share of mischief during college on VAX machines but ...
 
  


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
howto set path philipvarghese Linux - Newbie 2 12-13-2005 08:54 AM
Set the path systemwide/Set the path for a user with Slackware jayhel Slackware 1 06-12-2005 12:24 AM
Can't modify PATH globally for SOAP interaction... crazybio Linux - Newbie 2 12-03-2003 01:29 PM
Globally set PATH for all users glock19 Red Hat 8 11-09-2003 02:25 PM
removing path variables globally Nevetsmik103081 Linux - General 1 07-05-2003 01:17 PM


All times are GMT -5. The time now is 03:57 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration