2

Are all of the basic Unix commands available on all of the distributions of Linux including Ubuntu or are only certain commands inherited by Linux? Also, does GNU have it's own commands or does it include all of the same commands?

2 Answers2

2

There exists something known as POSIX standard. It's created by Open Group to have a certain standard of what commands should exist on a Unix-like system, certain system calls which system should implement, and basic devices and interfaces which should be present. In that sense, a POSIX-compliant system should be able to have utilities ( and those utilities should agree with standard behavior ) which another POSIX-compliant system has. In that sense, GNU utilities and Ubuntu are POSIX-compliant - they do have things outlined by the standard, although they have options ( such as -p in cp command ) which extend functionality.

"Inheritance" as such depends on whether or not Linux distribution is POSIX-compliant, which Ubuntu does comply with. Other distributions are outside of Ubuntu's control, even if they are based on Ubuntu, and Ubuntu is not necessarily responsible for how they implement commands on their side. Even compiling GNU coreutils can be done differently. So a different distribution may have GNU utilities, though they may be compiled differently.

However, don't focus so much on utilities, as on following POSIX and portable scripting and coding ways. That includes writing scripts for #!/bin/sh if you expect them to work on different OS, follow standard /bin/sh syntax ( which may lack certain /bin/bash features such as arrays ), and avoid GNU-specific flags when executing commands. You can't go wrong if you make your applications and scripts portable. Where you do need advanced features, be sure to check if the script is running on Ubuntu ( and it is stated in /etc/os-release file ) or someplace else.

Additional reading on topic:

Sergiy Kolodyazhnyy
  • 105,154
  • 20
  • 279
  • 497
0

The major distributions, including Ubuntu, include packages that provide versions of almost all Unix commands you might look for. They may not all be installed from the beginning, but there are generally versions available.

However, there are 2 details worth noting. First, there is no general, universal Unix OS. When you ask if Linux includes all of those functions, you are mistaken to think that there is, generally speaking, such a thing as Unix. There are competing implementations from IBM, or Berkeley. There will be slight differences in the way these things respond to commands. On a Macintosh, for example, open a terminal and you are in their version of Unix that is built on top of BSD Unix.

Second, because Ubuntu is an open system, authors of packages may exercise some differences of opinion about how arguments are handled. One of the surprises for me was the realization that each script's author decides how arguments are to be punctuated. Do they want parameters like "--color=auto" or do they want "--color auto". Many of the GNU/Linux routines will allow you to freely shuffle command line arguments, so "mkdir flop/gobble -p" or "mkdir -p flop/gobble" will have same effect, but on other Unixes they may insist the parameter comes first.

You need to read the help pages for each routine to find out what they want. This is the most disappointing/frustrating thing for me. Some programs, say "ps" or "tar" decide they don't want to use dashes any more and we have to pay attention. Now ps -aux and ps aux do the same thing, which irritates me a little bit.

The GNU/Linux family of programs make up the biggest chunk you will find, but not all, and even among the GNU/Linux set I notice some weird differences from one system to another. One of my favorite programs is a Perl script called "rename" that is still available on Ubuntu. However, if you install Fedora Linux, rename is replaced by an entirely different thing.

pauljohn32
  • 3,743