ubuntu - sudo -u参数到底是怎么执行的?
阿神
阿神 2017-04-24 09:09:56
0
1
821

ubuntu: sudo -u www-data echo $USER为什么输出结果是ubuntu不应该是www-data的吗?

阿神
阿神

闭关修行中......

reply all(1)
大家讲道理

Let’s take the Unix V6 source code for example. The linux one is not found. Take a look at the userstructure

struct user
{
  // ...
  char    u_uid;  // 实效用户id(effective user id)
  char    u_gid;  // 实效用户组id(effective group id)
  char    u_ruid; // 实际用户id(real user id)
  char    u_rgid; // 实际用户组id(real group id)
  // ...
} u;

Take effective users and actual users as an example. The actual user has been determined when logging in to the system, such as ubuntu用户的id108www-dataid105。若用ubuntu用户运行程序,则实效用户为108;若用sudo命令切换到www-data身份运行,则实效用户为 105,而实际用户仍为108,所以$USER还是实际用户ubuntu.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template