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用户的id是108,www-data的id是105。若用ubuntu用户运行程序,则实效用户为108;若用sudo命令切换到www-data身份运行,则实效用户为 105,而实际用户仍为108,所以$USER还是实际用户ubuntu.
Let’s take the Unix V6 source code for example. The linux one is not found. Take a look at the
user
structureTake 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
.