UNIX系统编程小结(二)(2)

1.there is no distinction to the UNIX kernel whether this data is text or binary.

    2.FIFO is a type of file used for communication between processed.It's sometimes called a named pipe.

3.if we used the stat function,we would never see symbolic links.用lstat才能处理symbolic links.

    4. set-user-ID:这个概念要特别注意。比如说,当一个文件被设置了set-user-ID后,而这个文件的owner是root,然后用一个非root的进程执行这个文件,那么该文件所执行的进程也将拥有root权限。比如说passwd命令就是一个set-user-ID程序。任何用户都可以修改密码,但/etc/passwd只能是root才有write的权利,所以这时set-usr_ID就可以发挥作用,让所有执行passwd的进程都可以向/etc/passwd中write。

5.whenever we want to open any type of file by name ,we must have execute permission in each directory mentioned in the name,including the current directory,if it is implied.This is why the execute permission bit for a directory is often called the search bit.这个比较好理解,对于一个目录来说,自然不可能去执行目录,所以目录的可执行性就是为了执行该目录下的文件作基础。

    6.目录的read权限仅仅是获得a list of all the filenames in the directory.目录的read权限与执行权限是很不相同的。

    7.we cannot create a new file in a directory unless we have write permission and execute permission in the directory.

   8.To delete an existing file,we need write permission and execute permission in the directory containing the file.We do not need read permission or write permission for the file itself.以前没有注意目录与文件之间的这样的权限的联系。

   9.当用gcc编译生成一个二进制文件后,用chmod u+s来设置set-user-ID。 当再用gcc更新该二进制文件后,set-user-ID就会消失

    10.read系统调用读的内容是不会自动加上'\0'的,所以在使用printf输出该内容的时候要手动加上'\0'

    11.open(filename,O_TRunC).就可以清空文件filename

    12.The i-nodes are fixed-length entries that contain most of the information about a file.Most of the information in the stat structure is obtained from the i-node.

    13.对目录做硬链接有可能使得文件系统出现循环,而这个循环是处理文件系统的很多工具都无法解决的。所以非常多的UNIX实现版本都不允许对目录做硬链接。apue上4.16有出现循环的例子

    14.We've mentioned before that to unlink a file,we must have write permission and execute permission in the directory containing the directory entry,as it is the directory entry that we will be removing.Also,we mentioned in Section 4.10(in apue)that if the sticky bit is set in this directory we must have write permission for the directory and one of the following:Own the file;Own the directory;Have superuser privileges.

    15.A symbolic link is an indirect pointer to a file,unlike the hard links,which pointed directly to the i-node of the file.

    16.

ln -s ../foo link_file  这里的../foo可以是不存在的文件,然后就像绝对路径一样,link_file 直接指向../foo。
例子:foo是一个目录。
ln -s ../foo foo/testdir
再ll  foo会显示
drwxr-xr-x 2 root root 4096 2012-12-06 22:37 ./
drwxr-xr-x 3 root root 4096 2012-12-06 22:37 ../
lrwxrwxrwx 1 root root    6 2012-12-06 22:37 testdir -> ../foo/

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/08fe7282040ac2c591b8c21cceaab22c.html