Linux – Are Linux commands interchangeable with Unix commands

linuxunix

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?

Best Answer

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.

Related Question