add a user to the sudoers linux为用户添加sudo权限

 

用sudo时提示"xxx is not in the sudoers file. This incident will be reported.其中XXX是你的用户名,也就是你的用户名没有权限使用sudo,我们只要修改一下/etc/sudoers文件就行了。下面是修改方 法:

1)进入超级用户模式。也就是输入"su -",系统会让你输入超级用户密码,输入密码后就进入了超级用户模式。(当然,你也可以直接用root用) 
2)添加文件的写权限。也就是输入命令"chmod u+w /etc/sudoers"。 
3)编辑/etc/sudoers文件。也就是输入命令"vim /etc/sudoers",输入"i"进入编辑模式,找到这一 行:"root ALL=(ALL) ALL"在起下面添加"xxx ALL=(ALL) ALL"(这里的xxx是你的用户名),然后保存(就是先按一 下Esc键,然后输入":wq")退出。 
4)撤销文件的写权限。也就是输入命令"chmod u-w /etc/sudoers"。


( ! ) Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 169
Call Stack
#TimeMemoryFunctionLocation
10.0011412440{main}( ).../index.php:0
20.11354262360Joomla\CMS\Application\SiteApplication->execute( ).../index.php:49
30.11354262360Joomla\CMS\Application\SiteApplication->doExecute( ).../CMSApplication.php:196
40.387911453224Joomla\CMS\Application\SiteApplication->dispatch( ).../SiteApplication.php:233
50.389011477504Joomla\CMS\Component\ComponentHelper::renderComponent( ).../SiteApplication.php:194
60.390211532832Joomla\CMS\Component\ComponentHelper::executeComponent( ).../ComponentHelper.php:377
70.390611560232require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ).../ComponentHelper.php:402
80.404911959864K2ControllerItem->execute( ).../k2.php:64
90.404911959864K2ControllerItem->display( ).../BaseController.php:710
100.419812610568K2ControllerItem->display( ).../item.php:78
110.419812610568K2ControllerItem->display( ).../controller.php:19
120.426212981608Joomla\CMS\Cache\Controller\ViewController->get( ).../BaseController.php:663
130.434213001976K2ViewItem->display( ).../ViewController.php:102
140.592515828784K2ViewItem->display( ).../view.html.php:742
150.592515828784K2ViewItem->loadTemplate( ).../HtmlView.php:230
160.598216001720include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php' ).../HtmlView.php:701

( ! ) Notice: Only variables should be assigned by reference in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php on line 478
Call Stack
#TimeMemoryFunctionLocation
10.0011412440{main}( ).../index.php:0
20.11354262360Joomla\CMS\Application\SiteApplication->execute( ).../index.php:49
30.11354262360Joomla\CMS\Application\SiteApplication->doExecute( ).../CMSApplication.php:196
40.387911453224Joomla\CMS\Application\SiteApplication->dispatch( ).../SiteApplication.php:233
50.389011477504Joomla\CMS\Component\ComponentHelper::renderComponent( ).../SiteApplication.php:194
60.390211532832Joomla\CMS\Component\ComponentHelper::executeComponent( ).../ComponentHelper.php:377
70.390611560232require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ).../ComponentHelper.php:402
80.404911959864K2ControllerItem->execute( ).../k2.php:64
90.404911959864K2ControllerItem->display( ).../BaseController.php:710
100.419812610568K2ControllerItem->display( ).../item.php:78
110.419812610568K2ControllerItem->display( ).../controller.php:19
120.426212981608Joomla\CMS\Cache\Controller\ViewController->get( ).../BaseController.php:663
130.434213001976K2ViewItem->display( ).../ViewController.php:102
140.592515828784K2ViewItem->display( ).../view.html.php:742
150.592515828784K2ViewItem->loadTemplate( ).../HtmlView.php:230
160.598216001720include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php' ).../HtmlView.php:701
back to top