Guide to Unix/Why Unix-like

From Wikibooks, open books for an open world
Jump to navigation Jump to search

The operating system installed on many servers and some workstations is Unix-like. But what does it mean to be like Unix? In this book, a Unix-like system is one that is similar to *BSD, GNU/Linux, Solaris, and the original Unix. Today, Mac OS X also qualifies as a Unix-like system.

General Concepts[edit | edit source]

As opposed to the (point and click) (graphical user interfaces) familiar to the general computer user, work usually gets done in unix in a text-based way, through what's known as the (command line shell).

As opposed to a (single-user) operating system which permits computer usage only by one person at one particular time, unix is a multi-user system, that allows access of multiple users to the computer simultaneously. Normally this is achieved by having the users access the system (remotely), through digital networks.

Whether accessing (remotely) or not, users need a (user account) before being granted access to the system; for the purposes of accounting, security, logging and resource management.

Since each particular user account has varying degrees of control over the system and its resources, having the ability to verify the true identity of a given user is crucial, so a method exists that verifies each user account (username) against a corresponding (password); in a process known as (logging in).

All Unix-like systems are similar. As with many operating systems for servers, the Unix-like systems can host multiple users and programs simultaneously. Some features are specific to Unix-like systems. The Unix-like systems provide a common command line interface called the shell. They also provide a common programming interface for the C language. The latter fact allows most Unix-like systems to run the same application software and desktop environments.

Unix is popular with programmers for a variety of reasons. A primary reason for its popularity is the building-block approach, where a suite of simple tools can be streamed together to produce very sophisticated results. Another reason is the philosophy that 'everything is a file', which means that a standardized set of operations and functionality can be performed on different file types (directories vs. regular files), hardware devices, and even system processes.

The shell[edit | edit source]

The shell is a program unique to Unix-like systems. It lets you type commands to launch other programs.

When you login to the system through a text-only terminal, Unix gives you a login shell. If your system has a graphical user interface such as GNOME, KDE, or anything that uses X Window System, you can access the shell through a program called a console emulator or terminal emulator. This emulates the text-only terminal that the shell requires for running.

Unfortunately, the shell and the commands are hard to learn. Further, many commands require "arguments" to work. For example, the rm command, which removes files, needs one or more "arguments" naming the files to delete. This book has a Explanations/Shell Prompt chapter which introduces the shell and its many features.

One can automate tasks by saving shell commands in a text file called a shell script. For example, shell scripts are used to boot the system.

The Unix shell is unique to Unix-like systems. Actually, there are multiple shells available for Unix. These shells extend their features in different ways. For the "Bourne-compatible" shells, the Wikibook Bourne Shell Scripting describes them. Most shell scripts are for Bourne-compatible shells.

The C language[edit | edit source]

Unix is the origin of the popular C language. Every program on the computer links to the C library which provides basic system features including access to the kernel. Even if an application is written in another language, like C++, it still links to the C library. An interpreted language like perl needs a perl interpreter linked to the C library.

This dependence on C can be a disadvantage. Most Unix-like kernels are written entirely in C; most common programs use C, C++ or Objective-C. It is difficult to add code to these programs in another language such as Fortran. In contrast, some non-Unix systems allow different programming languages to interact more easily.

This book does not describe how to program with C; that is the job of the book Programming:C. However, planned additions to this book will describe how to build and run Unix programs when you obtain their C source code.

The kernel and userland[edit | edit source]

Each Unix-like system has a kernel. This program controls the computer hardware.

All other programs on the system are part of userland, which means outside the kernel. The kernel shares the system between all running userland programs. To use the keyboard, the network connection, or another part of the hardware, a userland program must contact the kernel using system calls. The kernel allows multiple programs to share the hardware safely. It also switches programs in and out of the processors; thus it is a "multitasking" kernel.

For example, a web server like Apache, through the kernel, can simultaneously make multiple network connections to multiple web browsers. The same computer might also be running other server programs. As another example, a user on desktop system (with GNOME, KDE, or Xfce for example) can simultaneously open multiple windows containing file managers, word processors, and games. While the file manager copies files and the word processor prints a document, the user can play a Tetris clone at the same time.

Today, a very popular kernel is Linux. Linux qualifies as free and open source; even if Linux is running a server for millions of users, there is no licensing fee. Linux is usually combined with GNU to form the UNIX-like operating system, GNU/Linux (although there are some instances where it isn't combined with GNU). Thus, an easy way for a home user to obtain a Unix-like system is to install a GNU/Linux distribution that includes a friendly desktop.

When we want to configure the network connection, storage systems, or other parts of the hardware, we must often use special utility programs that configure the running kernel. Some of those programs are described in this book.

Neutral point of view[edit | edit source]

The intention is that this book has neutral point of view. Thus, this book claims not that Unix is always the best choice for any task. It will mention both advantages and disadvantages of Unix-like systems.