umask 怎样影响新建文件的权限?

1. umask 设置的不是默认权限,而是针对新建文件的一种权限限制。

2. 应用程序在创建文件时,会指定文件的权限 (mode)。而最终这个新建的文件的权限会是 (mode & ~umask).

# man 2 open

O_CREAT
    If  the  file does not exist it will be created.  The owner (user ID) of the file is set to the effective user ID of the process.  The group
    ownership (group ID) is set either to the effective group ID of the process or to the group ID of the parent directory  (depending  on  file
    system  type and mount options, and the mode of the parent directory, see the mount options bsdgroups and sysvgroups described in mount(8)).

    mode specifies the permissions to use in case a new file is created.  This argument must be supplied when O_CREAT is specified in flags;  if
    O_CREAT is not specified, then mode is ignored.  The effective permissions are modified by the process’s umask in the usual way: The permis-
    sions of the created file are (mode & ~umask).  Note that this mode only applies to future accesses of the newly created  file;  the  open()
    call that creates a read-only file may well return a read/write file descriptor.

继续阅读“umask 怎样影响新建文件的权限?”

How Linux measure CPU utilization with Hyper-Threading enabled?

There's no explicit definition of CPU utilization. Usually, we see CPU time as CPU utilization. The %id, %us, %sy etc seen in vmstat/iostat are CPU time.
~~~
CPU
These are percentages of total CPU time.
us: Time spent running non-kernel code. (user time, including nice time)
sy: Time spent running kernel code. (system time)
id: Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time.
wa: Time spent waiting for IO. Prior to Linux 2.5.41, included in idle.
st: Time stolen from a virtual machine. Prior to Linux 2.6.11, unknown.
~~~
继续阅读“How Linux measure CPU utilization with Hyper-Threading enabled?”