Chinaunix首页 | 论坛 | 博客
  • 博客访问: 682017
  • 博文数量: 111
  • 博客积分: 2109
  • 博客等级: 上尉
  • 技术积分: 1124
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-25 12:11
个人简介

通信码农,Emacs爱好者,业余IOS程序员,更业余的PM

文章分类

全部博文(111)

文章存档

2018年(2)

2016年(2)

2015年(2)

2014年(13)

2013年(21)

2012年(71)

分类: 其他平台

2013-04-08 20:04:44

首先我遇到cp文件,属性以及文件属主修改的问题。搜了一下,有这篇文章:

http://gl08301.blog.163.com/blog/static/1321188512011328111930608/

默认情况下,cp 命令会将原文件的属主更改为 EUID。
鸟哥的书上说 cp 的 -p 选项是可以用于在复制时保留源文件的permission.
可是我发现原来 cp -p 只是在root用户复制其他用户文件时才会保留原来的permission(permission不仅仅是那几个rwx,也包括属主、属组),而在EUID为普通用户使用时依旧更改属主和属组。
不过 使用 -p 选项可以使复制的目标文件和源文件保持相同的 mtime .


附:
-p 等于--preserve=模式,所有权,时间戳
      --preserve[=属性列表 保持指定的属性(默认:模式,所有权,时间戳),如果
 可能保持附加属性:环境、链接、xattr 等
      --sno-preserve=属性列表 不保留指定的文件属性
      --parents 复制前在目标目录创建来源文件路径中的所有目录

实测SCP跟CP在以上的描述是一致的。

===========================================================
关于ll命令里所有参数的意义:

http://blog.csdn.net/chenping314159/article/details/7555089


================================================================
关于UID 以及EUID :

翻了翻我的中文APUE果断坑爹货,找来了英文的原版:

4.4. Set-User-ID and Set-Group-ID

Every process has six or more IDs associated with it. These are shown in .


Figure 4.5. User IDs and group IDs associated with each process

real user ID
real group ID

who we really are

effective user ID
effective group ID
supplementary group IDs

used for file access permission checks

saved set-user-ID
saved set-group-ID

saved by exec functions


Normally, the effective user ID equals the real user ID, and the effective group ID equals the real group ID.

Every file has an owner and a group owner. The owner is specified by the st_uid member of the stat structure; the group owner, by the st_gid member.

When we execute a program file, the effective user ID of the process is usually the real user ID, and the effective group ID is usually the real group ID. But the capability exists to set a special flag in the file's mode word (st_mode) that says "when this file is executed, set the effective user ID of the process to be the owner of the file (st_uid)." Similarly, another bit can be set in the file's mode word that causes the effective group ID to be the group owner of the file (st_gid). These two bits in the file's mode word are called the set-user-ID bit and the set-group-ID bit.

For example, if the owner of the file is the superuser and if the file's set-user-ID bit is set, then while that program file is running as a process, it has superuser privileges. This happens regardless of the real user ID of the process that executes the file. As an example, the UNIX System program that allows anyone to change his or her password, passwd(1), is a set-user-ID program. This is required so that the program can write the new password to the password file, typically either /etc/passwd or /etc/shadow, files that should be writable only by the superuser. Because a process that is running set-user-ID to some other user usually assumes extra permissions, it must be written carefully. We'll discuss these types of programs in more detail in .

Returning to the stat function, the set-user-ID bit and the set-group-ID bit are contained in the file's st_mode value. These two bits can be tested against the constants S_ISUID and S_ISGID.


恍然发现自己的见解太狭隘,在我的潜意识里,总是把File跟Process显示的区分对立,仿佛File只是Process调用的资源,莫名之中
加入了大一时候利用文件存储data的意识。。真是太愚蠢了。Every thing is file.或许我刚刚理解了一点。




阅读(1333) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~