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 05-08-2012, 08:55 AM   #1
hemel1987
LQ Newbie
 
Registered: May 2012
Posts: 2

Rep: Reputation: 0
Question regarding the $PATH utility


Hello all,
I am using VMWare Workstation 7 and have installed a NEW COPY of RHEL Enterprise Edition 6.0 in it.
After i enter the bash shell as the SuperUser, and type the command:
echo $PATH and then press Enter
I am only able to see the following paths, namely:
1. /usr/kerberos/sbin; 2. /usr/kerberos/bin; 3. /usr/local/bin; 4. /usr/bin; 5. /bin; 6. /usr/X11R6/bin; 7. /home/user/bin
However, ideally there should be, in addition to the above, paths like: 8. /sbin; 9. /usr/sbin; 10. /home/user/sbin.

This problem seems to occur intermittently, so here are a few things that occur to me:
a. Since this is a fresh copy, and i haven't removed anything yet, i assume either its a problem with VMWare or my RHEL installation is corrupted?
b. Else as suggested by a friend, i may be able to use the export command to add the above paths. Incase this is possible, can someone also provide me with the syntax as to how the export command can be used for this scenario?
c. If there is any other scenario, i am overlooking with regards to this, please let me know?

Thanks for any help you can provide..

Regards,
hemel1987
 
Old 05-08-2012, 08:58 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
$10 says you are becoming root by running "su". This does not create a full root environment (SuperUser? What's that...??). either run "sudo -i" or "su -" to get a proper root login shell.

How on earth this could possibly be a VMware is way way beyond me!
 
Old 05-08-2012, 09:21 AM   #3
hemel1987
LQ Newbie
 
Registered: May 2012
Posts: 2

Original Poster
Rep: Reputation: 0
Smile

Hi,
Thanks for the info.

Using the 'su -' does provide an additional set of paths once i execute the echo command. As you mentioned, i overlooked the differences of 'su' and 'su -'.

I have another question regarding whether the 'export' command can be used to define additional paths as i had mentioned before?

Grateful to anyone who can provide me a syntax for the same..

Regards,
hemel1987

P.S. SuperUser was the alias that i had used for the root user. Some people here prefer to call it that. (http://static.linuxquestions.org/que...s_lq/icon7.gif)
 
Old 05-08-2012, 09:24 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
you can use export yes, but not in the way I expect you think it will work. You would generally add those commands to your ~/.bash_profile but be careful what you add, generally you really wouldn't need to change it, and if you think you do, you're doing it wrong. for example, your current directory should never be on your path. Other times sure you do need to. The script here, or system wide at /etc/profile, are where those paths are set, so you can see the current export commands in them directly.

I don't think anything **here** would prefer "SuperUser" over "root"

Last edited by acid_kewpie; 05-08-2012 at 09:25 AM.
 
Old 05-08-2012, 12:23 PM   #5
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,579

Rep: Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685
well

I think you are in for a lot of reading, and a lot of fun.

The earlier comments apply, I have no argument with anything said so far.
I do want to add one thing: $PATH is an environment variable, not a function or utility. The difference may be critical.
It does not accumulate: ie a second assignment REPLACES the first.

For example the following sequence
Code:
PATH=/bin;/usr/bin:/usr/local/bin
PATH=/sbin;/usr/sbin:/usr/local/sbin
echo $PATH
would generate output something like
Quote:
/sbin;/usr/sbin:/usr/local/sbin
There are some script and program utilities that allow you to pass a parameter, and (assuming it is a folder) they will check the current PATH and optionally add or remove it from the path as needed. (Testing to ensure that no path is added twice, etc.)
I know of no one who uses them extensively for anything other than startup scripts and automation. (pathmung come to mind)

An effect something LIKE those functions is easy to provide using a technique like this:
Code:
PATH=/bin;/usr/bin:/usr/local/bin
PATH=${PATH}:/sbin;/usr/sbin:/usr/local/sbin
PATH=${PATH}:~/bin
echo $PATH
might result in output that looks like
Quote:
/bin;/usr/bin:/usr/local/bin:/sbin;/usr/sbin:/usr/local/sbin:/root/bin
I hope this helps.
 
  


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
the utility ar is not in your PATH kountxero Debian 3 03-09-2007 02:49 AM
Unable to locate 'cc' utility in path SEATU Linux - Newbie 2 10-05-2005 12:22 AM
the utility zip is not in your path Nightmatrix Linux - Newbie 3 07-31-2003 01:56 PM
The utility zip is not in your path LinuxScott Linux - General 7 05-05-2003 04:55 PM

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

All times are GMT -5. The time now is 02:53 PM.

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
Open Source Consulting | Domain Registration