每天看点英文文档:APUE第三版(1)

网友投稿 872 2022-05-29

@[toc]

前言

这本书好厚啊,一千多页。

为什么会想看一本英文著作呢?

我想,不久后的将来,我会感谢现在自己的所作所为的,就像我依旧每天坚持锻炼一样。分开之后,我更加的透彻了,有些事情,要为自己而做。学习嘛,学给自己的;锻炼身体嘛,也是为了自己的未来,找到心仪对象的时候,不至于被嫌弃小肚男,虚胖等。

(其实是昨晚突然想通了,自己的能力上去了,两三千只不过是一周不到的工资而已,而且只是起步阶段。为什么要耽误了自己的前程呢?20-30岁,多投资自己。)

想明白这些之后,我就更加坚定了不再水文的信念了。顺便早上花半个小时和以前的放纵说了声再见(一口气清理了二十篇水文),以此明志!!!

为什么会选APUE呢?

可以说目前还是要强迫自己去看英文文档的,那为什么不挑一份自己喜欢的呢?

就像我当时,脑子一抽风就翻译了redis的配置文件一样,现在仍然为当初的“一时冲动”感到自豪、

写这么个专栏的目的是什么呢?

那当然不是为了传授什么知识了,反正都要翻译的,放在这里对我还能起一个正向促进的作用。==顺便看看能带动一个朋友算一个吧==(要是被带动了可以在评论区跟我说一声儿哦,要是人多我就组个社群,大家一起学会比较有动力,虽然我已经建了四五个社群了,但是英语社群还没试过)。

1、UNIX System Over view:Unix系统简介

1.1 Introduction

All operating systems provide services for programs they run. Typical services include a new program, opening a file, reading a file, allocating a region of memory, getting the current time of day, and so on. The focus of this text is to describe the services provided by various versions of the UNIX operating system.

Describing the UNIX System in a strictly linear fashion, without any forward references to terms that haven’t been described yet, is 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 an introduction to and overview of the services provided by the UNIX System for programmers new to this environment.

所有的操作系统都有提供程序运行的服务,这些服务包括:执行一个新的程序、打开一个文件、读取一个文件、分配一块内存、获取当前日期等。本文档的目的是讲述各版本的Unix系统所提供的服务。

如果不建立在对以往Unix系统有所了解的基础上,想要讲明白Unix系统,几乎是不可能的,或者,将会很枯燥。本章将从程序员的角度出发,快速浏览Unix系统。我们会使用一些贯穿全文的简单术语,我们将会在后文中介绍这些术语。本章还介绍并概述了UNIX系统为不熟悉此环境的程序员提供的服务。

1.2 UNIX Architecture(UNIX体系结构)

In a strict sense, an operating system can be defined as the software that controls the hardware resources of the computer and provides an environment under which programs can run. Generally, we call this software the kernel, since it is relatively small and resides at the core of the environment. Figure 1.1 shows a diagram of the UNIX System architecture.

什么是操作系统?严格意义上来说,操作系统属于软件范畴,它提供了对底层计算机资源的调度以及对任何程序都能运行的环境。

由于它小的很,且处于环境的核心部位,所以我们通常称之为内核。看下面的示意图:

The interface to the kernel is a layer of software called the system calls (the shaded portion in Figure 1.1). Libraries of common functions are built on top of the system callinterface, but applications are free to use both. (We talk more about system calls and library functions in Section 1.11.) The shell is a special application that 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 gives the computer its personality. This other software includes system utilities, applications, shells, libraries of common functions, and so on.

For example, Linux is the kernel used by the GNU operating system. Some people refer to this combination as the GNU/Linux operating system, but it is more commonly referred to as simply Linux. Although this usage may not be correct in a strict sense, it is understandable, given the dual meaning of the phrase operating system. (It also has the advantage of being more succinct.)

内核的接口是一层被称之为系统调用的软件(如果觉得别扭,请调整一下你对软件的定义),库函数(或者函数库)构建在系统调用之上,好在这它俩都是开放使用的。shell则是一种比较特殊的为其他应用运行提供接口的应用。

广义上来说,操作系统应该包含内核以及其它所有使得电脑能够被更简便操作的软件,其他软件包括系统实用程序、应用程序、shell、常用函数库等。

例如:Linux的内核使用的操作系统就是GNU,有些人称这种组合为 GNU/Linux,不过更常见的说法叫就是简易Linux系统,虽然这种说法可能不太准确,但是从“操作系统”的双重含义上来说,也是可以理解的了。

1.3 Logging In

When we log in to a UNIX system, we enter our login name, followed by our password. The system then looks up our login name in its password file, usually the file

/etc/passwd

If we look at our entry in the password file, we see that it’s composed of seven colon-separated fields: the login name, encrypted password, numeric user ID(205), numeric group ID (105),acomment field, home directory (/home/sar), and shell

每天看点英文文档:APUE第三版(1)

program (/bin/ksh).

sar:x:205:105:Stephen Rago:/home/sar:/bin/ksh

All contemporary systems have moved the encrypted password to a different file. In Chapter 6, we’ll look at these files and some functions to access them.

当我们登录UNIX系统时,我们需要先输入我们的账号,紧接着就是我们的密码,此后操作系统就会和预留在系统内的密码文件进行匹配,通常是这个文件:/etc/passwd。

如果我们进入到这个文件进行查看的时候,我们会看到这个文件的七个组成部分如下:登录名、加密过的密码、用户ID(数字)、用户组ID(数字)

账户领域、home目录,以及shell程序,例如:sar:x:205:105:Stephen Rago:/home/sar:/bin/ksh

所有当代系统都已将加密密码移动到另一个文件中。在第6章中,我们将介绍这些文件以及访问它们的一些函数。

Once we log in, some system information messages are typically displayed, and then we can type commands 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 the windows.) A shell is a command-line interpreter that reads user input and executes commands. The user input to a shell is normally from the terminal (an interactive shell) or sometimes from a file (called a shell script). The common shells in use are summarized in Figure 1.2.

登录之后,系统会显示一下系统信息,之后我们可以在shell命令行中输入我们的指令。shell是用于接收用户指令并运行的命令行接口,用户可以在终端操作shell,或通过文件的形式。下面总结了常用的shell:

The system knows which shell to execute for us based on the final field in our entry in the password file.

(此处省略一批对各种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 Almquist and later ported to Linux). The default user shell in FreeBSD is derived from the Almquist shell. The default shell in Mac OS X is the Bourne-again shell. Solaris, having its heritage in both BSD and System V, provides all the shells shown in Figure 1.2.

Throughout the text, we will use parenthetical notes such as this to describe historical notes and to compare different implementations of the UNIX System. Often the reason for a particular implementation technique becomes clear when the historical reasons are 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.

系统根据密码文件中的最后一组数据来判断要给我们提供哪种类型的shell服务。

不同版本的Linux使用的默认shell各不相同,有些发行版再次使用Bourne shell。其他人使用BSD替代Bourne shell,称为dash(Debian Almquist shell,最初由Kenneth Almquist编写,后来移植到Linux)。FreeBSD中的默认用户shell派生自Almquist shell。MacOSX中的默认shell是Bourne shell。Solaris继承了BSD和SystemV的传统,提供了图1.2所示的所有shell。

TCP/IP

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:SpringBoot系列:SpringBoot第十二篇:springboot集成apidoc
下一篇:【MongoDB】 1.入门 《MongoDB权威指南》【七天读书】
相关文章