Unix System Overview

Source: Internet
Author: User
Tags posix

Unix System Overview IntroductionAll operating systems provide services for programs they run. Typical services include executing a new program, opening a file, reading a file, allocating a region of memory, getting t He current time is, and so on. The focus of this text are to describe the services provided by various versions of the UNIX operating system.    describing the UNIX System in a strictly linear fashion, without any Forwar D references to terms that haven ' t been described yet, was nearly impossible (and would probably be boring). This chapter provides a whirlwind tour of the UNIX System from a programmer ' s perspective. We ' ll give some brief descriptions and examples of terms and concepts that appear throughout the text. We describe these features in much more detail in later chapters. This chapter also provides a introduction to and overview of the services provided by the UNIX System for programmers New To this environment. UNIX Architecture in a strict sense, an operating system can is defined as the software that controls the hardware Reso Urces of the computer and provides an environment under which programs can run. Generally, we call this software the kernel, since it's relatively small and resides at the core of the environment. Figure 1.1 shows a diagram of the UNIX System architecture. Figure 1.1 Architecture of the UNIX operating systemThe interface to the kernel are a layer of software called the system calls (the shaded portion in figure 1.1). Libraries of common functions is built on top of the system call interface, but applications is free to u Se both. (We talk more about system calls and the Library functions in section 1.11.) The shell is a special application this provides an interface for running other applications.In a broad sense, an operating system consists of the kernel and all the other software that makes a computer useful and g Ives the computer its personality.    This other software includes system utilities, applications, shells, libraries of common functions, and so on. For example, the Linux are the kernel used by the GNU operating system. Some people refer to this combination as the Gnu/linux operating system, but it's more commonly referred to as simply Lin Ux. Although this usage correct a strict sense, it is understandable, given the dual meaning of the phrase Operating System. (It also have the advantage of being more succinct.) Logging inlogin name when we log on to a UNIX system, we enter our login Name and followed by our password. The system then looks to our login name with its password file, usually the file /etc/passwd. If We look at your entry in the password file, we see that it's composed of seven colon-separated fields:the login name, E ncrypted password, numeric user ID (+), numeric group ID (+), a comment field, home directory (/home/fireway), and S Hell Program (/bin/bash).
fireway:x:1000:1000:fireway,,,:/home/fireway:/bin/bash
    All contemporary systems has moved the encrypted password to a different file. In Chapter 6, we'll look at the these files and some functions to access them. shells    Once We log in, some system information messages is typically displayed, and then we can type command s to the shell program. (Some Systems Start a window management program when you log in, but you generally end up with a shell running in one of T He windows.) A shell is a command-line interpreter that reads user input and executes commands. The user input to a shell was normally from the terminal (an interactive shell) or sometimes from a file (called a shell SC Ript). The common shells in use is summarized in Figure 1.2.
Name Path FreeBSD 8.0 Linux 3.2.0 Mac OS X 10.6.8 Solaris 10
Bourne Shell /bin/sh ? ? copy of Bash ?
Bourne-again Shell /bin/bash Optional ? ? ?
C Shell /bin/csh Link to tcsh Optional Link to tcsh ?
korn Shell /bin/ksh optional optional
tenex C shell /bin/tcsh
Figure 1.2  common shells used on UNIX systems    The system knows which shell to execute for US based on T He final field in we entry in the password file.    The Bourne shell, developed by Steve Bourne at Bell Labs, h As been in use since Version 7 and are provided with almost every UNIX system in existence. The control-flow constructs of the Bourne shell is reminiscent of Algol 68.    The C shell, developed by Bill J Oy at Berkeley, was provided with all the BSD releases. Additionally, the C shell is provided by + with System v/386 Release 3.2 and is also included in System V Release 4 (SVR4). (We'll have more than say about these different versions of the UNIX System in the next chapter.) The C shell is built on the 6th Edition shell and not the Bourne shell. Its control flow looks more like the C language, and it supports additional features that weren ' t provided by the Bourne s Hell:job control, a history mechanism, and command-line editing.&nBsp   The Korn Shell is considered a successor to the Bourne shell and were first provided with SVR4. The Korn shell, developed by David Korn at Bell Labs, runs on most UNIX systems, but before SVR4 is usually an extra-cost Add-on, so it isn't as widespread as the other and the shells. It is upward compatible with the Bourne shell and includes those features that made the C Shell Popular:job control, Comm And-line editing, and so on.    The Bourne-again shell are the GNU shell provided with all Linux systems. It is designed to being POSIX conformant, while still remaining compatible with the Bourne shell. It supports features from both the C shell and the Korn shell.    the Tenex C Shell was an enhanced version of th E C Shell. It borrows several features, such as command completion, from the Tenex operating system (developed on 1972 at Bolt Berane K and Newman). The Tenex C Shell adds many features to the C shell and are often used as a replacement for the C Shell.&nbsP   The shell is standardized in the POSIX 1003.2 standard. The specification was based in features from the Korn shell and Bourne shell.
    The default shell used by different Linux distributions varies . Some distributions Use the Bourne-again shell. Others Use the BSD replacement for the Bourne shell, called dash (Debian Almquist shell, originally written by Kenneth Alm Quist and later ported to Linux). The default user shell in FreeBSD was derived from the Almquist shell. The default shell in Mac OS X is the Bourne-again shell. Solaris, has its heritage in both BSD and System V, provides all the shells shown in Figure 1.2. Free ports of the shells is available on the Internet.
    Throughout the text, we'll use parenthetical notes such as this to describe historical notes an D to compare different implementations of the UNIX System. Often the reason for a particular implementation technique becomes clear when the historical reasons is described.
Throughout this text, we'll show interactive shell examples to execute a program that we ' ve developed. These examples use features common to the Bourne shell, the Korn shell, and the bourne-again shell. Files and Directoriesinput and Outputprograms and processeserror handlinguser identificationuser ID The user ID from OU R entry in the password file was a numeric value that identifies us to the system. This user ID was assigned by the system administrator if our login name was assigned, and we cannot change it. The user ID is normally assigned to being unique for every user. We'll see how the kernel uses the user ID to check whether we had the appropriate permissions to perform certain operatio    Ns. We call the user whose user ID is 0 either root or the superuser. The entry in the password file normally have a login name of root, and we refer to the special privileges of this user as Superuser Privileges. As we ' ll see in Chapter 4, if a process has superuser privileges, the most file permission checks is bypassed. Some operating system functions is restricted to the superuser. The superuser has a free rein over the system.
Client versions of Mac OS X ship with the Superuser account disabled; Server versions ship with the account Alre Ady enabled. Instructions is available on Apple's Web site describing how to enable it. See http://support.apple.com/kb/HT1528.
Group ID We entry in the password file also specifies our numeric group ID. This, too, was assigned by the system administrator when we login name is assigned. Typically, the password file contains multiple entries that specify the same group ID. Groups is normally used to collect users together into projects or departments. This allows the sharing of resources, such as files, and among members of the same group. We'll see in sections 4.5 that we can set the permissions to a file so this all members of a group can access the file, whe    Reas Others outside the group cannot. There is also a group file, maps group names into numeric group IDs. The group file is usually /etc/group.    The use of numeric user IDs and numeric group IDs for Permissi ONS is historical. With every file on disk, the file system stores both the user ID and the group ID of a file ' s owner. Storing both of these values requires only four bytes, assuming this is stored as a two-byte integer. If the full ASCII login name and group name were used instead, additional disk space would is required. In addition, comparing strings during permission checks are more expensive than comparing integers. Users, however, work better with names than and numbers, so the password file maintains the mapping between login Names and user IDs, and the group file provides the mapping between group names and group IDs. The ls-l command, for example, prints the login name of the owner of a file, using the password file to map the Numeric user ID into the corresponding login name.
Early UNIX systems used 16-bit integers to represent user and group IDs. Contemporary UNIX systems use 32-bit integers.
Example the program in Figure 1.9 Prints the user ID and the group ID.
  
 
  1. /**
  2. * 文件名: intro/uidgid.c
  3. * 内容:prints the user ID and the group ID
  4. * 时间: 2016年 09月 16日 星期五 22:40:34 CST
  5. * firewaywei
  6. */
  7. #include "apue.h"
  8. int
  9. main(void)
  10. {
  11. printf("uid = %d, gid = %d\n", getuid(), getgid());
  12. exit(0);
  13. }
Figure 1.9 Print User ID and group ID We call the functions Getuid and Getgid to return the user ID and the group ID. Running the program yields
$./uidgid
UID = +, gid = 1000
$ su
Password:
#./uidgid
UID = 0, gid = 0
Supplementary group IDs in addition to the group ID specified in the password file for a login name, most versions of T He UNIX System allow a user to belong to other groups. This practice started with 4.2BSD, which allowed a user to belong the up to additional groups. These supplementary group IDs is obtained at login time by reading the file /etc/groupAnd finding the first entries that list the user as a member. As we shall see on the next chapter, POSIX requires that a system support at least 8 supplementary groups per process, but Most systems support at least 16.SignalsTime Valuessystem Calls and Library functionssummary reference advanced Programming in th E UNIX envinronment, 2013 "Chapter 1. UNIX System over View

Unix System Overview

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.