View previous topic :: View next topic |
Author |
Message |
XST1 Apprentice

Joined: 27 Jan 2004 Posts: 163
|
Posted: Sun Dec 26, 2004 11:38 pm Post subject: shell question |
|
|
I have a beginner question on the linux shell. If I were to type, for example 'gaim' in any directory, it would automaticly load. Where is the location that points all these shortcuts to the proper executable? |
|
Back to top |
|
 |
noup l33t


Joined: 21 Mar 2003 Posts: 917
|
Posted: Sun Dec 26, 2004 11:56 pm Post subject: |
|
|
check out your environment's PATH variable. when you run a command that corresponds to a program, it's in the directories specified by the PATH variable that the executable's name will be searched. _________________ noup. |
|
Back to top |
|
 |
arwing n00b


Joined: 21 Feb 2004 Posts: 61
|
Posted: Mon Dec 27, 2004 12:11 am Post subject: |
|
|
most are in /usr/bin or /bin or /usr/X11R6/bin, and pretty much every folder named bin. |
|
Back to top |
|
 |
XST1 Apprentice

Joined: 27 Jan 2004 Posts: 163
|
Posted: Mon Dec 27, 2004 3:19 am Post subject: |
|
|
arwing wrote: | most are in /usr/bin or /bin or /usr/X11R6/bin, and pretty much every folder named bin. |
So your saying, if i were to add an executable called "asdf" into /usr/bin, /bin, or /usr/X11/bin then anywhere I type asdf (in any folder regardless), it will automatically call that executible?
How would it know which one to execute if there are multiple ones in multible folders? |
|
Back to top |
|
 |
wdreinhart Guru

Joined: 11 Jun 2003 Posts: 569 Location: 4QFJ12345678
|
Posted: Mon Dec 27, 2004 3:32 am Post subject: |
|
|
XST1 wrote: | So your saying, if i were to add an executable called "asdf" into /usr/bin, /bin, or /usr/X11/bin then anywhere I type asdf (in any folder regardless), it will automatically call that executible?
How would it know which one to execute if there are multiple ones in multible folders? |
When there is more than one executable with the same name, it will execute whichever program it finds first. Look at your PATH environment variable (echo $PATH). If /usr/bin comes before /home/user/bin or /usr/X11R6/bin then the one in /usr/bin would be executed. |
|
Back to top |
|
 |
Jake Veteran

Joined: 31 Jul 2003 Posts: 1132
|
Posted: Mon Dec 27, 2004 3:43 am Post subject: |
|
|
XST1 wrote: | So your saying, if i were to add an executable called "asdf" into /usr/bin, /bin, or /usr/X11/bin then anywhere I type asdf (in any folder regardless), it will automatically call that executible? |
It'll still need execute premission set. If you write a shell script, for example, you'll need to do "chmod +x script.sh".
Also, the proper place for such programs is bin in your home directory, but Gentoo doesn't put that in your PATH by default, and I don't know the proper way to add it to your PATH.
XST1 wrote: | How would it know which one to execute if there are multiple ones in multible folders? |
Try "echo $PATH". /bin should be listed before /usr/bin, meaning /bin/bash would be executed before /usr/bin/bash (if it existed). You can also run, for example, "which bash" to get the exact path of what would be executed if you entered bash at the prompt. |
|
Back to top |
|
 |
malone Apprentice


Joined: 19 Feb 2004 Posts: 159 Location: The p-n junction.
|
Posted: Mon Dec 27, 2004 6:41 am Post subject: |
|
|
To add a directory to your PATH, put something like the following in ~/.bashrc
Code: | PATH="${PATH}:${HOME}/.scripts:/path/to/dir" |
_________________ malone |
|
Back to top |
|
 |
|