Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
shell question
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
XST1
Apprentice
Apprentice


Joined: 27 Jan 2004
Posts: 163

PostPosted: Sun Dec 26, 2004 11:38 pm    Post subject: shell question Reply with quote

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
View user's profile Send private message
noup
l33t
l33t


Joined: 21 Mar 2003
Posts: 917

PostPosted: Sun Dec 26, 2004 11:56 pm    Post subject: Reply with quote

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
View user's profile Send private message
arwing
n00b
n00b


Joined: 21 Feb 2004
Posts: 61

PostPosted: Mon Dec 27, 2004 12:11 am    Post subject: Reply with quote

most are in /usr/bin or /bin or /usr/X11R6/bin, and pretty much every folder named bin.
Back to top
View user's profile Send private message
XST1
Apprentice
Apprentice


Joined: 27 Jan 2004
Posts: 163

PostPosted: Mon Dec 27, 2004 3:19 am    Post subject: Reply with quote

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
View user's profile Send private message
wdreinhart
Guru
Guru


Joined: 11 Jun 2003
Posts: 569
Location: 4QFJ12345678

PostPosted: Mon Dec 27, 2004 3:32 am    Post subject: Reply with quote

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
View user's profile Send private message
Jake
Veteran
Veteran


Joined: 31 Jul 2003
Posts: 1132

PostPosted: Mon Dec 27, 2004 3:43 am    Post subject: Reply with quote

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
View user's profile Send private message
malone
Apprentice
Apprentice


Joined: 19 Feb 2004
Posts: 159
Location: The p-n junction.

PostPosted: Mon Dec 27, 2004 6:41 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum