LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-01-2012, 01:39 PM   #1
moony10
LQ Newbie
 
Registered: Feb 2012
Posts: 5

Rep: Reputation: Disabled
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?
 
Old 03-01-2012, 01:54 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,561

Rep: Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127Reputation: 2127
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.
 
Old 03-01-2012, 01:59 PM   #3
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 8,718

Rep: Reputation: 887Reputation: 887Reputation: 887Reputation: 887Reputation: 887Reputation: 887Reputation: 887
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;
 
Old 03-01-2012, 02:29 PM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 19,328

Rep: Reputation: 4471Reputation: 4471Reputation: 4471Reputation: 4471Reputation: 4471Reputation: 4471Reputation: 4471Reputation: 4471Reputation: 4471Reputation: 4471Reputation: 4471
Quote:
Originally Posted by moony10 View Post
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.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Questions and answer on Linux/Fedora and Red Hat Enterprise Linux, 5th Ed. msbernice Linux - Newbie 7 07-21-2010 07:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:59 AM.

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