1-History&Concepts

What is Unix

Unix is a Multi-user, multi-process and multi-access operating system.

这三个multiple其实是互不影响的(orthogonal),像x, y, z轴一样。

先来说说unix的历史,Unix在20世纪60年代中晚期诞生于AT&T的贝尔实验室中。最初发布的Unix中的一些重要设计因素到如今都还在使用:

其中一个设计是“Unix哲学”,建立小的模块化的应用,只做一件事情并把它做好。可以通过combine多个简单的小命令来完成复杂的工作。

另一个是单一文件结构,程序可以通过它互相通讯。这也是为什么在Linux里说“一切都是文件”-包括硬件设备文件,和提供系统信息及其他数据的特殊文件。

unix中只有file 和 process。all devices are represented by file。-------一切皆文件

file disk,devices,input 和 output of commands 都被看作文件。

对所有文件(目录、字符设备、块设备、 套接字、打印机等)操作,读写都可用fopen()/fclose()/fwrite()/fread()等函数进行处理。屏蔽了硬件的区别,所有设备都抽象成文件,提供统一的接口给用户。这就是“一切皆是文件”的思想。

The fundamental component of information in Unix is the byte stream. It allows files, devices and even programs to be used interchangeably as the source or destination of data; and thus allows the underlying machine architecture to be hidden from the user.

文件是被动(passive)的entity,允许写入和输出。进程是积极的(active)的entity,进程的起点都是一个文件,当被执行的时候才变成进程。进程都是有生命的。

UNIX主要有:

command line user interface

can combine simple command to realize complex commands

hierarchical file system

TREE FOR FILE & PROCESS

Unix File System(UFS): inverted tree, single root directory which contains files. *Unix system contains only one file system。但是这个file system是可以扩展的,可以连接很多其他的tree。所以最终看起来还是一个tree。因为只有一个tree,所以所有文件都在一个name space上。

Process tree :process tree, all processes have a parent process and may have child process. every process has a PID (process ID) and PPID (parent process ID).

第一个process叫做init,它是init machine to make it ready for user的过程的一部分。init创建了一个child process to set up machine and prompt user to login. 一旦user login了,有一个新的child process被创建了,用来让用户输入命令,这个新的child process就是shell。对于每一个用户输入的命令,shell产生一个新的process,因为我们可以说shell是这些processes的parent。shell 本身是init process的child process。(一些命令不会产生新的process,例如ls)



What are Users

users are owners of files and processes, so in Unix everything(file+process) carries a UID(User ID) and GID(group ID).

user一定需要先login才能使用unix系统,通过login,系统会确定用户信息,然后verify用户可以access的资源和associate的文件。明确地说,user会被放在整个file system的一个sub-system上然后被给一个initial process。

当user第一次login的时候,他们会得到initial process(shell)和file(home directory)。然后后面产生的任何file和process都会有这个user id 和 group id在上面。GID的意义在于确定用户能够使用哪些shared files and commands。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 为何叫做 shell ? shell prompt(PS1) 与 Carriage Return(CR) 的关系?...
    Zero___阅读 8,368评论 3 49
  • linux资料总章2.1 1.0写的不好抱歉 但是2.0已经改了很多 但是错误还是无法避免 以后资料会慢慢更新 大...
    数据革命阅读 14,186评论 2 33
  • 曾经父亲与我就像是山一样的存在,在我的世界里,只要有父亲在,那么所有的问题都不会是问题。父亲的臂膀像是坚实的脊梁,...
    樱小落阅读 1,774评论 0 0
  • 村长不是官,我说的这个村长更不是官。 他是在工地上给我们烧饭的伙夫,因为热心快肠,总给别人解决一些小困难,所以大伙...
    别山举水阅读 4,494评论 16 46
  • 感谢老天在我最美的年华里,让我遇见了你们⋯⋯ 我和她们是小学同学,但刚开始我们并不是很好的朋友,甚至没有太多的交集...
    凌小诗阅读 2,256评论 1 1