操作系统基本概念(文件,shell)(get a intuitive feel)

文件(承接上一次博客)
在minix3中每个文件和目录被分配一个11位的保护码,其中包含3个3位的区域,一个给拥有者一个给拥有者组中的其他成员(管理员给使用者分组),剩下的3位区域给所有使用者。这三位二进制数的每一位分别表示读权限,写权限和执行权限因此
这三位叫做rwx bits(read,write,execute)。对于目录而言x表示搜索权限。
在一个文件被读或写之前,他必须被打开,在这个时候检查文件的访问权限,如果允许访问系统返回一个小的整数叫做file descriptor用于后续操作,如果访问被禁止,系统返回一个错误码-1。
shell
The operating system is the code that carries out the system calls.Editors,compilers,assemblers,linker,and command interpreters definitely are not part of the operating system,even though they are important and useful.尽管shell不是
操作系统的一部分,但它用到了操作系统的很多特性,它体现系统调用是如何被使用的。他也是用户和终端以及操作系统
之间最初的界面(除非用户使用图形接口)。
csh,ksh,zsh,bash都是shell,他们都支持以下特性:
When any user logs in, a shell is started up. The shell has the terminal as
standard input and standard output. It starts out by typing the prompt, a character
such as a dollar sign, which tells the user that the shell is waiting to accept a com-
mand. If the user now types
date
for example, the shell creates a child process and runs the date program as the
child. While the child process is running, the shell waits for it to terminate.
When the child finishes, the shell types the prompt again and tries to read the next
input line.
The user can specify that standard output be redirected to a file, for example,
date >file
Similarly, standard input can be redirected, as in
sort >file2
which invokes the sort program with input taken from file1 and output sent to
file2.
The output of one program can be used as the input for another program by
connecting them with a pipe(百度,或以后讨论). Thus
cat file1 file2 file3 | sort >/dev/lp
invokes the cat program to concatenate three files and send the output to sort to
arrange all the lines in alphabetical order. The output of sort is redirected to the
file /dev/lp, typically the printer.
If a user puts an ampersand after a command, the shell does not wait for it to
complete. Instead it just gives a prompt immediately. Consequently,
cat file1 file2 file3 | sort >/dev/lp &
starts up the sort as a background job, allowing the user to continue working nor-
mally while the sort is going on. The shell has a number of other interesting fea-
tures, which we do not have space to discuss here. Most books for UNIX
beginners are useful for MINIX 3 users who want to learn more about using the
system. Examples are Ray and Ray (2003) and Herborth (2005).

你可能感兴趣的:(计算机系统)