Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Just wanted to know - is there a standard path where uname is installed? e.g. /usr/bin/uname or /bin/uname

I'm asking with regards to HP-UX, AIX, SunOS and RedHat Linux

Is there a common path in which all of the above contain uname? If not, how can I know on which OS my script is executing?

share|improve this question
up vote 1 down vote accepted

uname should be in a location that's in your $PATH which almost always includes /bin and /usr/bin. You should be able to rely on executing uname without specifying a full path.

share|improve this answer
Doesn't it matter which "copy" of uname i get? – RonK Aug 25 '10 at 19:12
@RonK: Do any of your systems have uname in more than one place? The designers of some versions of Linux or Unix choose to put some utilities in different locations. Sometimes utilities appear in more than one location on the same system. If this is the case, they are often symlinked or hardlinked and so it makes no difference. Occasionally, utilities will be located in more than one place that are different versions. At least one of those will not be in either /bin or /usr/bin. If they're different and one is in each of those locations it's a mistake or bad design. – Dennis Williamson Aug 25 '10 at 19:38
uname is a basic utility so I don't think you should worry about it at all. – Dennis Williamson Aug 25 '10 at 19:38
@Dennis Williamson: What if my script is the one responsible for setting the PATH? Can I assume /bin or /usr/bin is are already in the path even for a brand new account? (I am no SysAdmin so forgive me if the question sounds stupid) – RonK Aug 25 '10 at 20:17
@RonK: Try this at a command prompt: env -i bash -c 'echo $PATH'. That will show you what the default PATH is. The shell creates that value by default. If your script sets a PATH this way: PATH=$PATH:/more/dirs then the exported value will be there along with your new value. If you do it this way: PATH=/some/dir then the old value will be replaced instead of appended to. What do you mean "brand new account" - this is the first you've mentioned that. If you're talking about adding new users (or service accounts) then yes, they get a default environment... – Dennis Williamson Aug 25 '10 at 21:32

If you are making a general purpose script, you can include /usr/bin and /bin in the pathname if you are unsure. Then it would not matter.

share|improve this answer

You can never rely on binaries being in a particular location across all operating systems. Generally, for portability's sake, you will want to rely on the path being set properly. But safe programs tends to lock down the path (and Perl's taint mode modifies the path too). Thus perhaps offer the user of the script the ability to configure the binaries to be used.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.