LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   linux equivalent of the path in windows (https://www.linuxquestions.org/questions/linux-newbie-8/linux-equivalent-of-the-path-in-windows-117918/)

mep]-[isto 11-19-2003 03:25 PM

linux equivalent of the path in windows
 
hi all, i ve had a look around and cant seem to find what im looking for so ive come here for help. my question is; how do i go about defining where bash looks for binary executable files when you type just the name in on a command line? example: as a user, if i type gaim it launches gaim automatically, even though gaim is in /usr/local/bin. the reaso i ask this is because for some reason im not sure about, when im root and i type commands it wont look in the same places it would as when im in my normal user account.

my ultimate aim is to add /usr/local/sbin/ to roots path

thanks in advance!

vincebs 11-19-2003 03:33 PM

I know how to set the PATH temporarily but everytime I restart bash it resets it to the default.

PATH= ....

How do I set it permanently? And also the Java classpath variable, how do I set that too?

linuxbotx 11-19-2003 03:34 PM

The path would be in your .bashrc file.

Mara 11-19-2003 03:44 PM

You can change in in .bashrc or /etc/profiles. The line will be
export PATH=$PATH:/usr/local/sbin

vincebs 11-19-2003 04:36 PM

Quote:

Originally posted by Mara
You can change in in .bashrc or /etc/profiles. The line will be
export PATH=$PATH:/usr/local/sbin

Sorry, I don't get what this line does. Does it export the variable to /usr/local/sbin? Or is it adding /usr/local/sbin to the PATH? If so, where does the system get $PATH from?

So what would I do to add, for example, "/downloads" to my PATH?

mep]-[isto 11-19-2003 06:15 PM

as far as i understand that would add /usr/local/sbin to $PATH, though im not sure where $PATH is initially defined, where would that be? it seems by default the path for my account 'mick' includes /usr/bin, /usr/local/bin etc but root is very restritive and only seems to include /sbin type directories

also i dont have /etc/profiles or .bashrc; would it be possible to explain how profiles is structured? i.e a directory or a file and what advantages/disadvantages it has over the .bashrc file. also im presuming .bashrc would be located in my home or root dir (respectively)?

sorry for all the questions, only reason is i really like knowing why more than how :P (though i guess the why would be ponitless without the how!)

Mara 11-20-2003 03:34 PM

The command export PATH=$PATH:/usr/local/sbin adds /usr/local/sbin to current PATH. The PATH variable is usually defined in /etc/profiles. The command looks like this
export PATH=/bin:/usr/bin:/sbin:/usr/sbin
There can be more directories. When you don't use $PATH inside it's definition (after =), the old one is deleted and the directories listed (separated by : as you can see) in the command are used.

A common mistake is adding new directory to PATH this way:
export PATH=/usr/local/sbin
The problem is that it deleted the old PATH, so only /usr/local/sbin would be in it, making the system use hard.

To add any other directory, just use something like
export PATH=$PATH:/downloads
or, if you have more dirs to add
export PATH=$PATH:/downloads:/important/executables

/etc/profiles defines PATH for all users. If you change something here, all users will be affected. On the other hand, /home/yourlogin/.bashrc is your own, private file. If you add such a line here, only your PATH will change.

mep]-[isto 11-21-2003 03:13 PM

thanks mara, and all who replied! good info :) nice to hear people explaining things aswell. i think the thing i enjoy most about linux is udnerstanding it, not just knowing to do this and that and when asked why i think...hmm, i dont know.

thanks to all! :) oh and btw this is a damn fine forum, good ppl offering good help!

mep]-[isto 11-21-2003 03:17 PM

i just had a look in my /etc directory and couldnt find profiles, the cloest thing i found was profile.d (a directory), is this what im looking for? if not...what is this? and if this isnt it, is profiles a file or directory?

thanks!

bosewicht 11-21-2003 03:21 PM

as far as java and defiining the path here is a really nice tutorial i have found and posted a couple of times....

http://www.dougsparling.com/comp/ho...x_java-1.3.html

bosewicht 11-21-2003 03:22 PM

i don't think the first link works

http://www.dougsparling.com/comp/how..._java-1.3.html


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