LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Linux Questions Help (https://www.linuxquestions.org/questions/linux-newbie-8/linux-questions-help-932207/)

moony10 03-01-2012 12:39 PM

Linux Questions Help
 
Need some help answering the following questions. I appreciate any help.

. What is the purpose of the PATH variable?
a. Set up your PATH variable so that it causes the shell to search the following directories in order:
• /usr/local/bin
• /usr/bin/Xl1
• /usr/bin
• /bin
• /usr/kerberos/bin
• Your own bin directory (usually bin or .bin in your home directory)
• The working directory

b. If a file named doit is in /usr/bin and also in your ~/bin, which one doit will be executed? (Assume that you have execute permission for both of the files.)
c. If your PATH variable is not set to search the working directory, how can you execute a program located there?
d. Which command can you use to add the directory /user/games to the end of the list of directories in your PATH?

suicidaleggroll 03-01-2012 12:54 PM

The PATH environment variable tells the shell where to look for a program when you type its name on the command line.

For example, to search for files, you'll often use the program "find". "find" is just a regular program like any other, and it generally lives in "/usr/bin/". So that you don't have to manually type out "/usr/bin/find" every time you want to run it, you can instead add "/usr/bin/" to your PATH. Once "/usr/bin/" is in your PATH, you can just type "find", and the shell will locate and run the program.

The rest sounds like a homework problem, so I'll forego answering them for you.

business_kid 03-01-2012 12:59 PM

Purpose - see question 2.

A. yes
B the first one in the PATH variable
C. direct call with pathname e.g. ~/bin/dolt, or ./dolt if you're in ~/bin/
D. PATH=/usr/games:$PATH;

TB0ne 03-01-2012 01:29 PM

Quote:

Originally Posted by moony10 (Post 4616206)
Need some help answering the following questions. I appreciate any help.

. What is the purpose of the PATH variable?
a. Set up your PATH variable so that it causes the shell to search the following directories in order:
• /usr/local/bin
• /usr/bin/Xl1
• /usr/bin
• /bin
• /usr/kerberos/bin
• Your own bin directory (usually bin or .bin in your home directory)
• The working directory

b. If a file named doit is in /usr/bin and also in your ~/bin, which one doit will be executed? (Assume that you have execute permission for both of the files.)
c. If your PATH variable is not set to search the working directory, how can you execute a program located there?
d. Which command can you use to add the directory /user/games to the end of the list of directories in your PATH?

Don't just come and post your homework questions. Read the LQ Rules.

We will always be glad to HELP, but you have to show effort on your part.


All times are GMT -5. The time now is 12:52 PM.