Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I find that some commands, for example, ls and pwd, can be used on both Linux and Unix systems.

  • Is it that all Linux commands can be used in the Unix systems, and all Unix commands can be used in Linux?
  • Or just that all the Linux commands can run on Unix but not all Unix commands can run on Linux.
  • Or that all Unix commands can run on Linux, but not all Linux commands can run on Unix?
  • Or is there a reference to show me which commands can run on both Linux and Unix, and where both have their own unique command?
share|improve this question
27  
Read about "POSIX". –  Daniel Andersson Feb 15 '12 at 9:04
1  
Note that it's not a "Linux" command, it's a GNU command. The GNU tools can be installed on FreeBSD, for example. –  new123456 Feb 16 '12 at 1:57
2  
Heck, the GNU tools can even be installed on Unix. –  MSalters Feb 16 '12 at 12:33
add comment

5 Answers

up vote 37 down vote accepted

Daniel Andersson's comment about POSIX is the real answer here: there is a standard called POSIX which defines the core of a UNIX-like system, both in terms of shell commands and system calls. In theory, if you write software to the POSIX spec, it should be possible to compile and run it on any UNIX, Linux, BSD etc system.

http://pubs.opengroup.org/onlinepubs/009695399/mindex.html will give you a definitive answer as to what constitutes POSIX, but that's not a useful answer for practical purposes. Someone else may have good command references for common differences between Linux systems and other UNIX-like systems.

One specific example: "killall" on Linux kills all processes with a particular name. On Solaris, it shuts the system down. Important not to use the wrong one.

share|improve this answer
9  
@tchrist- if you really think that, type "sudo apt-get" on Mac OS X and see how far it gets you. –  David Robinson Feb 15 '12 at 15:56
7  
@tchrist when Ted Wong mentioned Linux he was obviously talking about the operating system that is also know as GNU/Linux and it says right there in the name that "GNU's Not Unix!" ;) –  João Portela Feb 15 '12 at 16:36
4  
Actually, as I understand it, Mac OS X IS a certified Unix--something very few (if any) of the Linux variants achieved. Obviously this would be just a matter of certification to a very basic standard. –  Bill K Feb 15 '12 at 17:00
2  
@tchrist L inux I s N ot U ni X –  Dave Feb 15 '12 at 23:48
4  
@Dave Bah. Don’t be lame. Call a spade a spade, a cat a cat, and remember that a rose by any other name shall still smell as sweet. Hie thee to a Windows box and learn what Unix is not. But Linux is of course Unix. –  tchrist Feb 16 '12 at 1:13
show 3 more comments

On solaris you just have to add /usr/gnu/bin to your path or exchange it with /usr/bin and your command sets will be very similar

share|improve this answer
add comment

Most Linux distributions today come with lots of essential GNU software and the GNU Toolchain. GNU was a project to rewrite a free-as-in-freedom copy of Unix that later got paired together with the Linux kernel. When you use ls on a Unix machine you're using the original/what's become of the original ls. When you use ls on GNU/Linux, you're using the GNU ls which was written from scratch to be the same as ls. However, not all GNU software is exactly the same as its Unix counterparts. Now that Unix has essentially turned into BSD, GNU/Linux distros may also contain the BSD version of that tool. For example, bsdtar and tar come to mind.

tl;dr: They aren't the exact same code, but they are meant to for the most part be exactly the same.

share|improve this answer
2  
As for differences the ps is the most annoying example I can think of. Different switches on different systems (Linux, AIX and Solaris). Also different format of output. Though the purpose of that command is the same on all systems. –  elmo Feb 15 '12 at 11:34
add comment

What you need to consider first is that the commands are actually small programs, in that sense not necessarily a part of the operating system if you split hairs. The old and classic ones have been around for a long time, and are included in most *nix systems. Just how "complete" the OS is depends on what comes with the package.

As an example most recovery/emergency CDs you can boot from contain a slim Linux distro, you would find that some typical commands might not be featured in these systems, purely because they would not be needed in most cases.

share|improve this answer
add comment

You didn't specify which UNIX you're talking about (BSD, System V...). There's no universal (UNIX) answer. Each UNIX variant has its own custom commands (take Mac OS X for example), so even between UNIXes there are different commands. Usually old commands (like ls, pwd, cd, cp, mv, rm...) tend to be the same on all UNIX flavors (including Linux).

share|improve this answer
5  
officially trademarked as UNIX –  m0skit0 Feb 15 '12 at 16:06
add comment

Your Answer

 
discard

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.