shell学习笔记(原书摘录)

来源:互联网 发布:linux 查看机器配置 编辑:程序博客网 时间:2024/06/11 18:30

最近在看UNIX® Shells by Example Fourth Edition,一些知识要点,原文摘录,看了这些,让自己对shell的理解不断的上升、深入,希望能有时间再多看一遍。

利用两天时间看了chapter1、2、3,感觉收获很大。不过接下去的grep  sed  awk才是shell的精华啊。一天一章节,现在记录一些疑惑粗浅的知识,希望能在第二遍阅读的时候,整理出完好的笔记。

再次推荐阅读这本shell的书籍,附件中有下载。


1、shell is a special program, but what is the pid?

2、pstree: displays all processes as a tree with its root being the first processess that runs ,called init.

3、system calls: is  a request for kernel services and is the only way a process can access the system's hardware.

4、To remove zombie processes, the system must be rebooted.

5、fork:The kernel loads this new program into memory in place of the shell that called it. The child shell, then, is overlaid with the new program.

6、在终端上敲下命令ls的shell过程:

      For example, if the command ls had been typed at the command line, the parent shell wouldfork a child process and go to sleep. The child shell would thenexec (overlay) thels program in its place. Thels program would run in place of the child, inheriting all the environment variables, open files, user information, and state information. When the new process finished execution, it would exit and the parent shell would wake up. A prompt would appear on the screen, and the shell would wait for another command. If you are interested in knowing how a command exited, each shell has a special built-in variable that contains the exit status of the last command that terminated.

7、on bash shell ,  a command exec success($? = 0)  failed($? = 1)

8、The EUID and EGID determine what permissions a process has access to when reading, writing, or executing files. If the EUID of a process and the real UID of the owner of the file are the same, the process has the owner's access permissions for the file. If the EGID and real GID of a process are the same, the process has the owner's group privileges.

      The caller's EUID must match the owner's UID of the file, or the owner must be superuser.

9.When a file descriptor is assigned to something other than a terminal, it is calledI/O redirection

10.

Arithmetic:The Bourne shell does not support arithmetic. UNIX/Linux commands must be used to perform calculations.

n=`expr 5 + 5`echo $n
11.Regular expression metacharacters are evaluated by the programs that perform pattern matching, such as vi, grep, sed, and awk
12.Do not confuse this metacharacter with the shell wildcard (*). They are totally different. The shell asterisk matches for zero or more of any character, whereas the regular expression asterisk matches for zero or more of the preceding character.
13.the meaning of grep and the origin of its name. It means "globally search for the regular expression (RE) and print out the line."
原创粉丝点击