Unix Commands Question/Book Recommendations
Ok this is a 2 parter. First of all, this may sound stupid, but are all Unix Commands on Linux Distros? Does any Linux Distro add any.
And commands like....pwd or......ssh, like what are these "written" in programming language wise. C?
Se开发者_C百科cond part, What is a good book that lists and explains all the Unix commands (or at least most of them)
thanks
The biggest difference you will find between the Unix (and its derivatives) and Linux commands are the options that exist for those commands. Specifically, the GNU versions tend to add more functionality to their commands but their use is not portable to non-GNU systems like BSD or Unix.
A common example of this would be the GNU
sed -i
option which allows you to do an in-place edit on the file. Non-GNU versions of sed require you to first write to a temp file then copy the temp file over the original.In order to help define what is portable code and what is not, there are the POSIX and SUS specifications. Any shell which claims to be POSIX compliant guarantees that any code written against the POSIX standard will perform identically. The
bash
shell is a POSIX compliant shell but that doesn't mean all bash commands are POSIX compliant.For your second question, yes, most commands in binary form were written in the C language. Sometimes you'll find certain commands that are written in scripting languages such as
perl
,python
orbash
. Therename
command is one example that exists in bothperl
and binary form written from C.For your 3rd question on Book Recommendations, see this SO question
Not all linux distributions come with one and the same set of commands. There is, however, The Single UNIX® Specification, which lists canonical commands and utilities.
In short: The majority of programs is written in C.
Again, take a look at The Single UNIX® Specification to get an overview. Once you have opened a terminal with a shell, just press Tab - this will yield a list of commands on your machine.
$ # press Display all 3358 possibilities? (y or n)
Most commands have man pages, too, if you want to know more about them.
$ man pwd
First off, I think it would be better to refer to shells here, since each *nix distro can come with numerous shells. To answer your questions:
Many commands are available on all shells, but of course each shell can add their own commands. Additionally, many programs can add their own shell accessible programs.
I found the O'Reilly book on learning unix shells to be extremely useful.
I learned much of the basics from http://linuxcommand.org/. Maybe that will help you and the price is right
And visiting it just now I see that the author has compiled it into book for free under a CC licence. Check out the description and a download link here.
1. Yes / C. 2. O'Reilly, and Apress
I. Common Commands
There is a core set of commands that true Unix and all of the Linux distros have.
For some time, the distributions have been evolving to install a set of packages, and since there are thousands and thousands to choose from, the idea of a "base system" has given way to that of a "default install". For example, some can be installed without X or graphics.
Some of the original Unix commands or rewrites of them are available with BSD licenses, and you will run into many of those on true Unix, *BSD, and on the Mac. There are also a set of GPL-licensed rewrites of the Unix commands. These tend to be quite elaborate, leading to confusing manpages, but sometimes they are considerably more useful than the original Unix program. Groff is a good example of a case where the original code has been completely superseded. In any case, Linux distros stick as much as possible to the GPL/GNU versions.
Language: The core commands are almost entirely written in C. As the C++ and C compilers have merged, a few packages are written in C++. A few are written in Posix shell code. As the distributions have grown in scope and size, more packages that are included are written in languages like Perl and Python. I presume you may see packages written in Ruby as well. (Ruby comes with the Mac now.)
II. Books
O'Reilly and Apress are two good sources for Unix and Linux publications.
III. Well, there wasn't a III but Mac OS X is built on a version of Unix. You can learn Unix perfectly well in the Terminal app on your Mac.
精彩评论