当我们使用sudo命令切换用户的时候可能会遇到提示以下错误: xxx is not in the sudoers file. This incident will be reported. 其中xxx是你当前的用户名,究其原因是用户没有加入到sudo的配置文件里. 切换到root用户,运行visudo命令 [gordon@localhost Workspace]$ su Password: [root@localhost Workspace]# visudo 在打开的配置文件中,找到root ALL=(ALL) ALL,在下面添加一行 xxx ALL=(ALL) ALL ,其中xxx是你要加入的用户名称,在vi下可以用”/root”来查找 ## Next comes the main part: which users can run what software on ## which machines (the sudoers file can be shared between multiple ## systems). ## Syntax: ## ## user MACHINE=COMMANDS ## ## The COMMANDS section may have other options added to it. ## ## Allow root to run any commands anywhere root ALL=(ALL) ALL gordon ALL=(ALL) ALL 输入:wq保存并退出配置文件,再次使用sudo命令就不会有上面的提示了。