Are Linux commands interchangeable with Unix commands?
Solution 1:
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.
Solution 2:
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.
Solution 3:
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).
Solution 4:
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.
Solution 5:
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