ubuntu: sudo -u www-data echo $USER
为什么输出结果是ubuntu
不应该是www-data
的吗?
大家讲道理2017-04-24 09:11:56
Let’s take the Unix V6 source code for example. The linux one is not found. Take a look at the user
structure
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
用户的id
是108
,www-data
的id
是105
。若用ubuntu
用户运行程序,则实效用户为108
;若用sudo
命令切换到www-data
身份运行,则实效用户为 105
,而实际用户仍为108
,所以$USER
还是实际用户ubuntu
.