APUE学习笔记之UNIX系统概述(1)
APUE 全稱: Advanced Programming in the Unix Environment.
參考書籍為人民郵電出版社出版的Advanced Programming in the Unix Environment英文版第二版,筆記先列英文原文,下面是自己翻譯版,由于英文水平問題,錯(cuò)誤的地方還望大家指正,自己的總結(jié)就沒有英文原版拉。
1 UNIX System Overview (Unix 系統(tǒng)概述)
1.1 Introduction (介紹)
All operationg systems provide services for programs they run. (所有的操作系統(tǒng)為它們所允許的程序提供服務(wù)。)
1.2 UNIX Architecture (Unix 架構(gòu))
In a strict sence, 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. (嚴(yán)格來說,操作系統(tǒng)被定義為控制計(jì)算機(jī)的硬件資源的軟件和為程序提供允許的環(huán)境。)
In a borad sense, an operating system is the kernel and all the other software that makes a computer useful and gives the computer its personality.(寬泛的說, 操作系統(tǒng)是“核心” 和其它一些軟件,它們使得計(jì)算機(jī)非常有用的和個(gè)性話的。)
1.3 Logging in (登錄)
Login name (登錄名)
The /etc/passwd file:
???????
yanjf: the login name (登錄名:?惟一; 大小寫是敏感; “*” 表示該賬號(hào)被查封了,系統(tǒng)不允許持有該賬號(hào)的用戶登錄)
x: encrypted password (加密密碼:用一個(gè)“x”來代替,將/etc /shadow作為真正的口令文件)
1000:?numeric user ID (用戶ID:數(shù)值;在某些特定目的下,系統(tǒng)中可以存在多個(gè)擁有不同注冊(cè)名、但UID相同的用戶,事實(shí)上,這些用戶是同一個(gè)用戶)
1000: numeric group ID (用戶組ID:數(shù)值;每個(gè)用戶可以同時(shí)屬于多個(gè)組;在/etc/group文件中指明一個(gè)組所包含用戶)
yanjf,,,: a command field (注釋字段:包含有關(guān)用戶的一些信息,如用戶的真實(shí)姓名、辦公室地址、聯(lián)系電話,mail和finger等程序利用這些信息來標(biāo)識(shí)系統(tǒng)的用戶)
/home/yanjf: home directory (主目錄:超級(jí)用戶root的主目錄為/root;而其它個(gè)人用戶在/home目錄下均有自己獨(dú)立的工作環(huán)境)
/bin/bash: shell program (默認(rèn)shell腳本)
Shells
A shell is a command-line interpreter that read users input and executes commands.(shell 是一個(gè)命令行解釋器,它讀取用戶輸入并且執(zhí)行命令。)
| Name | Path |
| Bourne shell | /bin/sh |
| Bourne-again shell | /bin/bash |
| C shell | /bin/csh |
| Korn shell | /bin/ksh |
| TENEX C shell | /bin/tcsh |
1.4 Files and Directories (文件和目錄)
File System (文件系統(tǒng))
The UNIX file system is a hierarchical arrangement of directories and files. (UNIX 文件系統(tǒng)是按層次組織的目錄和文件。)
A directory is a file that contains directory entries. (目錄是一個(gè)包含目錄條目的文件。)
We can think of each directory entry as containing a filename along with a structure of information describing the attributes of the file.(我們可以認(rèn)為每個(gè)目錄條目是包含一個(gè)文件名和一個(gè)描述文件屬性的結(jié)構(gòu)體。)
Filename
The names in a directory are called filenames. (目錄下的名稱稱為文件名。)
The only two characters that cannot appear in a filenames are the slash character(/) and the null character. (只有 “/” 和 null 不能出現(xiàn)在文件名中。)
/ 分隔路徑中的文件名。null 終止路徑。
Two filenames are automatically created whenever a new directory is created: . and .. 。Dot refers to the current directory, and dot-dot refers to the parent directory.(新建目錄是自動(dòng)創(chuàng)建 "."? 和 ".." 兩個(gè)文件名。“.”指向當(dāng)前目錄,“..”指向父目錄)
In the root directory , dot-dot is the same as dot. (在根目錄下,"." 和 “..” 指向同一個(gè)目錄。)
Today, almost all commercial UNIX file system support at least 255-character filenames. (當(dāng)今,幾乎所有的商用Unix文件系統(tǒng)都支持至少255個(gè)字符的文件名。)
Pathname (路徑名)
A sequence of one or more filenames, separated by slashes and optionally starting with a slash, forms a pathname. (由/開頭或者由/分隔的文件名組成路徑。)
A pathname that begins with a slash is called an absolute pathname; otherwise, it's called a relative pathname. (/開頭的路徑稱為絕對(duì)路徑,否則為相對(duì)路徑。)
Working Directory (工作目錄)
Every process has a working directory, sometimes called the current working directory. (每個(gè)進(jìn)程都有一個(gè)工作目錄,有時(shí)稱為當(dāng)前工作目錄。)
Home Directory (主目錄)
When we log in, the working direcotry is set to our home directory. (登錄后工作目錄默認(rèn)為我們的主目錄。)
1.5 Input and Output (輸入和輸出)
File Descriptors (文件描述符)
Standard Input, Standard Output, and Standard Error (標(biāo)準(zhǔn)輸入,標(biāo)準(zhǔn)輸出,標(biāo)準(zhǔn)錯(cuò)誤輸出)
Redirected (>) (重定向) : ls > file.list
Unbuffered I/O (無緩沖 I/O)
Unbuffered I/O is provided by the functions open, read, write, lseek, and close.
Standard I/O (標(biāo)準(zhǔn) I/O)
The standard I/O functions provides a buffered interface to the unbuffered I/O functions. (標(biāo)準(zhǔn)I/O函數(shù)為無緩沖I/O函數(shù)提供拉一個(gè)緩沖接口。)
1.6 Programs and Processes (程序和進(jìn)程)
Program (程序)
A programs is an executable file residing on disk in a directory. (程序是記錄在硬盤上的一個(gè)目錄中的可執(zhí)行文件。)
Processes and Process ID (進(jìn)程和進(jìn)程ID)
An executing instance of a program is called a process. (一個(gè)程序執(zhí)行時(shí)的實(shí)例稱為進(jìn)程。)
The UNIX System guarantees that ervery process has a unique numeric identifier called the process ID. (Unix 系統(tǒng)確保每個(gè)進(jìn)程有一個(gè)唯一的數(shù)值標(biāo)識(shí)稱為進(jìn)程ID(非負(fù)整數(shù)).)
Process Control (進(jìn)程控制)
There are three primary functions for process control: fork, exec, and waitpid. (三個(gè)主要的進(jìn)程控制函數(shù):fork,exec, waitpid。)
Threads and Thread IDs (線程和線程ID)
All the threads within a process share the same address space, file descriptors, stacks, and process-related attributes. (所有在同一個(gè)進(jìn)程內(nèi)的線程共享相同的地址空間,文件描述符,棧,和進(jìn)程相關(guān)的屬性。)
1.7 Error Handing (錯(cuò)誤處理)
When an error occurs in one of the Unix System functions, a negative value is often returned, and the integer errno is usually set to a value that gives additional information. (當(dāng)Unix系統(tǒng)函數(shù)發(fā)生錯(cuò)誤時(shí),經(jīng)常會(huì)返回一個(gè)負(fù)數(shù),同時(shí)errno這個(gè)整數(shù)會(huì)被設(shè)置為一個(gè)值,來提供額外的信息。)
Error Recovery (錯(cuò)誤恢復(fù))
A fatal error hao no recovery action. (致命的錯(cuò)誤沒有恢復(fù)動(dòng)作。)
Nonfatal errors, on the other hand, can sometimes bu dealt with more robustly. (另一方面,非致命性的錯(cuò)誤可以處理的更健壯。)
1.8 User Identification (用戶標(biāo)識(shí))
User ID (用戶ID)
The user ID from our entry in the password file is a numeric value that identifies us to the system. (passwd文件中的用戶ID是一個(gè)數(shù)值作為我們的系統(tǒng)標(biāo)識(shí))
We call the user whose user ID is 0 either root or superuser. (用戶ID為0的稱為root 或者 superuser。)
Group ID (用戶組ID)
Our entry in the password file alse specifies our numberic group ID. (我們的passwd文件也指定啦我們的用戶組ID。)
There is also a group file that maps group names into numeric group IDs. (有一個(gè)組文件來匹配組名和用戶組ID。)
The /etc/group file:
?
組名:口令:組標(biāo)識(shí)號(hào):組內(nèi)用戶列表
we call the functions getuid and getgid to return the user ID and the group ID. (我們使用 getuid 和 getgid 函數(shù)返回用戶ID和組ID。)
1.9 Signals (信號(hào))
Signals are a technique used to notify a process that some condition has occurred. (信號(hào)是一種用來通知進(jìn)程某些條件發(fā)生的技術(shù)。)
1.10 Time Values (時(shí)間值)
Calendar time: This value counts the number of seconds since the Epoch: 00:00:00 January 1, 1970, Coordinated Universal Time(UTC). timt_t holds these time values.
Process time: This is also called CPU time and measures the central processor resources used by a process. (測量進(jìn)程所使用的中央處理器資源)clock_t holds these time values.
Clock time: sometimes called wall clock time is the amount of time the process takes to run. (進(jìn)程允許的時(shí)間量。)
User CPU time: the CPU time attributed to user instructions. (執(zhí)行用戶指令的時(shí)間)
System CPU time: the CPU time attributed to the kernel when it executes on behalf of the process. (進(jìn)程占用內(nèi)核的時(shí)間。)
1.11 System Calls and Library Functions (系統(tǒng)調(diào)用和庫函數(shù))
All implementations of the UNIX System provide a well-defined, limited number of entry points directly into the kernel called system calls. (Unix 系統(tǒng)的實(shí)現(xiàn)都提供一個(gè)明確的,有限的指向核心的入口點(diǎn),稱為”system calls“。)
The technique used on UNIX systems is for each system call to have a function of the same name in the standard C library. (每個(gè)系統(tǒng)調(diào)用在標(biāo)準(zhǔn)C庫函數(shù)有一個(gè)同名的函數(shù)。)
An application can call either a system call or a library routine. Also realize that many library routines invoke a system call. (應(yīng)用程序可以調(diào)用系統(tǒng)調(diào)用和庫例程,另外,許多庫例程調(diào)用啦系統(tǒng)調(diào)用。)
1.12 Summary (總結(jié))
This chapter has been a short tour of the UNIX System. (這章簡單的了解拉下Unix系統(tǒng)。)
The next chapter is about standardization of the UNIX System and the effect of work in this area on current systems. (下章是關(guān)于Unix 系統(tǒng)標(biāo)準(zhǔn)化和當(dāng)前系統(tǒng)在這方面的影響。)
(完)
?
轉(zhuǎn)載于:https://www.cnblogs.com/yanjf/p/3321956.html
總結(jié)
以上是生活随笔為你收集整理的APUE学习笔记之UNIX系统概述(1)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ie6/IE8/IE9/谷歌以及火狐等浏
- 下一篇: Yii AR Model 查询