[comment]: # translation:outdated

[comment]: # ({2de5c46f-6f1ad3f2})
# 9 以 root 用户身份运行agent 

Zabbix从 **5.0.0** 版本开始，Zabbix agent 服务的启动文件 [官方包](https://www.zabbix.com/download?zabbix=5.0&os_distribution=red_hat_enterprise_linux&os_version=8&db=mysql) 已更新为显示包含 `User` 及 `Group`的参数。
两者都设置为 `zabbix`。

由于agent会通过以systemd服务文件指定的用户运行，而忽略`zabbix_agentd.conf`配置文件，这也将导致不再支持通过配置`zabbix_agentd.conf`  来指定运行用户 。
可以通过如下描述的修改来实现agent以root用户运行。

[comment]: # ({/2de5c46f-6f1ad3f2})

[comment]: # ({86009682-2f6d2fe8})
### Zabbix agent
要覆盖缺省用户和用户组，执行：
    systemctl edit zabbix-agent
然后，增加如下内容：

    [Service]
    User=root
    Group=root

重新加载守护进程并重启 zabbix-agent 服务

    systemctl daemon-reload
    systemctl restart zabbix-agent

对于**Zabbix agent**，依然要在  `zabbix_agentd.conf` 文件中重新启用配置用户的功能。因此，为了以 root 身份运行 zabbix agent，您仍然需要编辑 agent [配置文件]（/manual/annex/config/zabbix_agentd）并指定 `User=root` 以及 `AllowRoot=1` 两个参数。

[comment]: # ({/86009682-2f6d2fe8})

[comment]: # ({13ba87ac-f2ff86e2})
### Zabbix agent 2
要覆盖缺省用户和用户组，执行：
    systemctl edit zabbix-agent2
然后，增加如下内容：

    [Service]
    User=root
    Group=root

重新加载守护进程并重启 zabbix-agent 服务

    systemctl daemon-reload
    systemctl restart zabbix-agent2

对于**Zabbix agent2**，运行用户完全取决于上述修改，不再需要其他修改。

[comment]: # ({/13ba87ac-f2ff86e2})
