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.0003397976{main}( ).../index.php:0
20.02931348368Joomla\CMS\Application\SiteApplication->execute( ).../index.php:49
30.02931348368Joomla\CMS\Application\SiteApplication->doExecute( ).../CMSApplication.php:196
40.12143056088Joomla\CMS\Application\SiteApplication->dispatch( $component = ??? ).../SiteApplication.php:233
50.12183080504Joomla\CMS\Component\ComponentHelper::renderComponent( $option = 'com_k2', $params = ??? ).../SiteApplication.php:194
60.12223135856Joomla\CMS\Component\ComponentHelper::executeComponent( $path = '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ).../ComponentHelper.php:377
70.12233152912require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php ).../ComponentHelper.php:402
80.12643383712K2ControllerItem->execute( $task = '' ).../k2.php:64
90.12643383712K2ControllerItem->display( $cachable = ???, $urlparams = ??? ).../BaseController.php:710
100.12983622232K2ControllerItem->display( $cachable = TRUE, $urlparams = ['id' => 'INT', 'print' => 'INT', 'lang' => 'CMD', 'Itemid' => 'INT', 'm' => 'INT', 'amp' => 'INT', 'tmpl' => 'CMD', 'template' => 'CMD'] ).../item.php:78
110.12983622232K2ControllerItem->display( $cachable = TRUE, $urlparams = ['id' => 'INT', 'print' => 'INT', 'lang' => 'CMD', 'Itemid' => 'INT', 'm' => 'INT', 'amp' => 'INT', 'tmpl' => 'CMD', 'template' => 'CMD'] ).../controller.php:19
120.13063645136Joomla\CMS\Cache\Controller\ViewController->get( $view = class K2ViewItem { public $document = class Joomla\CMS\Document\HtmlDocument { public $_links = [...]; public $_custom = [...]; public $template = NULL; public $baseurl = NULL; public $params = NULL; public $_file = NULL; protected $_template = ''; protected $_template_tags = [...]; protected $_caching = NULL; private $_html5 = NULL; public $title = 'add a user to the sudoers linux为用户添加sudo权限'; public $description = '&nbsp; 用sudo时提示&#34;xxx is not in the sudoers file. This incident will be reported.其中XXX是你的用户名,也就是你的用户名没有权限使用sudo,我们只要修改一下/etc/sudoers文件就行了。下面是修改方 法:...'; public $link = ''; public $base = 'https://www.shan.info/item/364-add-a-user-to-the-sudoers.html'; public $language = 'en-gb'; public $direction = 'ltr'; public $_generator = 'Joomla! - Open Source Content Management'; public $_mdate = ''; public $_tab = '\t'; public $_lineEnd = '\n'; public $_charset = 'utf-8'; public $_mime = 'text/html'; public $_namespace = ''; public $_profile = ''; public $_scripts = [...]; public $_script = [...]; protected $scriptOptions = [...]; public $_styleSheets = [...]; public $_style = [...]; public $_metaTags = [...]; public $_engine = NULL; public $_type = 'html'; protected $mediaVersion = '15dbf078d61dbbf76811992dd0143dd9' }; protected $_name = 'item'; protected $_models = ['itemlist' => class K2ModelItemlist { ... }, 'item' => class K2ModelItem { ... }]; protected $_basePath = '/var/www/vhosts/shan.info/httpdocs/components/com_k2'; protected $_defaultModel = 'item'; protected $_layout = 'item'; protected $_layoutExt = 'php'; protected $_layoutTemplate = '_'; protected $_path = ['template' => [...], 'helper' => [...]]; protected $_template = '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php'; protected $_output = NULL; protected $_escape = 'htmlspecialchars'; protected $_charset = 'UTF-8'; protected $_errors = []; public $baseurl = ''; public $addLink = NULL; public $inlineCommentsModeration = FALSE; public $item = class stdClass { public $id = '364'; public $title = 'add a user to the sudoers linux为用户添加sudo权限'; public $alias = 'add-a-user-to-the-sudoers'; public $catid = '49'; public $published = '1'; public $introtext = '<p>\r\n\t&nbsp;</p>\r\n<pre style="margin-top: 0px; margin-bottom: 10px; padding: 5px; border: 0px; font-size: 14px; vertical-align: baseline; background-color: rgb(224, 224, 224); overflow: auto; width: auto; max-height: 600px; font-family: \'Ubuntu Mono\', \'Ubuntu Beta Mono A\', Consolas, \'Bitstream Vera Sans Mono\', \'Courier New\', Courier, monospace; color: rgb(51, 51, 51); line-height: 17px;">\r\n</pre>\r\n<p>\r\n\t<span style="color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size'; public $fulltext = ''; public $video = NULL; public $gallery = NULL; public $extra_fields = NULL; public $extra_fields_search = ''; public $created = '2013-01-09 18:02:43'; public $created_by = '63'; public $created_by_alias = ''; public $checked_out = '63'; public $checked_out_time = '2013-01-09 18:06:02'; public $modified = '0000-00-00 00:00:00'; public $modified_by = '0'; public $publish_up = '2013-01-09 18:02:43'; public $publish_down = '0000-00-00 00:00:00'; public $trash = '0'; public $access = '1'; public $ordering = '23'; public $featured = '0'; public $featured_ordering = '0'; public $image_caption = ''; public $image_credits = ''; public $video_caption = ''; public $video_credits = ''; public $hits = '1755'; public $params = class Joomla\Registry\Registry { ... }; public $metadesc = ''; public $metadata = 'robots=\nauthor='; public $metakey = ''; public $plugins = ''; public $language = '*'; public $category = class TableK2Category { ... }; public $link = '/item/364-add-a-user-to-the-sudoers.html'; public $printLink = '/item/364-add-a-user-to-the-sudoers.html?tmpl=component&amp;print=1'; public $tags = [...]; public $imageXSmall = ''; public $imageSmall = ''; public $imageMedium = ''; public $imageLarge = ''; public $imageXLarge = ''; public $attachments = [...]; public $rawTitle = 'add a user to the sudoers linux为用户添加sudo权限'; public $author = class Joomla\CMS\User\User { ... }; public $videoType = 'allvideos'; public $text = '<p>\r\n\t&nbsp;</p>\r\n<pre style="margin-top: 0px; margin-bottom: 10px; padding: 5px; border: 0px; font-size: 14px; vertical-align: baseline; background-color: rgb(224, 224, 224); overflow: auto; width: auto; max-height: 600px; font-family: \'Ubuntu Mono\', \'Ubuntu Beta Mono A\', Consolas, \'Bitstream Vera Sans Mono\', \'Courier New\', Courier, monospace; color: rgb(51, 51, 51); line-height: 17px;">\r\n</pre>\r\n<p>\r\n\t<span style="color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size'; public $event = class stdClass { ... }; public $jcfields = [...]; public $image = ''; public $imageWidth = '600'; public $comments = [...]; public $numOfComments = 0; public $nextLink = '/item/367-centos-6-epel.html'; public $nextTitle = 'centos 6 epel'; public $nextImageXSmall = ''; public $nextImageSmall = ''; public $nextImageMedium = ''; public $nextImageLarge = ''; public $nextImageXLarge = ''; public $previousLink = '/item/286-centos-memcached-php-5-2-17-ius-repo.html'; public $previousTitle = 'centos memcached php 5.2.17 ius repo'; public $previousImageXSmall = ''; public $previousImageSmall = ''; public $previousImageMedium = ''; public $previousImageLarge = ''; public $previousImageXLarge = ''; public $absoluteURL = 'https://www.shan.info/item/364-add-a-user-to-the-sudoers.html'; public $langTagForFB = 'en_GB'; public $langTagForTW = 'en-gb'; public $langTagForLI = 'en_GB'; public $sharinglink = 'https://www.shan.info/item/364-add-a-user-to-the-sudoers.html'; public $socialLink = 'https%3A%2F%2Fwww.shan.info%2Fitem%2F364-add-a-user-to-the-sudoers.html'; public $twitterURL = 'https://twitter.com/intent/tweet?text=add+a+user+to+the+sudoers+linux%E4%B8%BA%E7%94%A8%E6%88%B7%E6%B7%BB%E5%8A%A0sudo%E6%9D%83%E9%99%90&amp;url=https%3A%2F%2Fwww.shan.info%2Fitem%2F364-add-a-user-to-the-sudoers.html'; public $langTagForGP = ''; public $emailLink = '/component/mailto/?tmpl=component&amp;template=gk_publisher&amp;link=23c5d31d39398fd8492a4a4520bd1fde524bb975' }; public $user = class Joomla\CMS\User\User { protected $isRoot = FALSE; public $id = 0; public $name = NULL; public $username = NULL; public $email = NULL; public $password = NULL; public $password_clear = ''; public $block = NULL; public $sendEmail = 0; public $registerDate = NULL; public $lastvisitDate = NULL; public $activation = NULL; public $params = NULL; public $groups = [...]; public $guest = 1; public $lastResetTime = NULL; public $resetCount = NULL; public $requireReset = NULL; protected $_params = class Joomla\Registry\Registry { ... }; protected $_authGroups = NULL; protected $_authLevels = [...]; protected $_authActions = NULL; protected $_errorMsg = NULL; protected $userHelper = class Joomla\CMS\User\UserWrapper { ... }; protected $_errors = [...]; public $aid = 0; public $gid = 1 }; public $params = class Joomla\Registry\Registry { protected $data = class stdClass { ... }; protected $initialized = TRUE; public $separator = '.' }; public $pagination = class Joomla\CMS\Pagination\Pagination { public $limitstart = 0; public $limit = 10; public $total = 0; public $prefix = ''; public $pagesStart = 1; public $pagesStop = 0; public $pagesCurrent = 1; public $pagesTotal = 0; public $hideEmptyLimitstart = FALSE; protected $viewall = FALSE; protected $additionalUrlParams = [...]; protected $app = class Joomla\CMS\Application\SiteApplication { ... }; protected $data = NULL } }, $method = 'display', $id = ???, $wrkarounds = ??? ).../BaseController.php:663
130.13213731040K2ViewItem->display( $tpl = ??? ).../ViewController.php:102
140.16144394560K2ViewItem->display( $tpl = NULL ).../view.html.php:742
150.16144394560K2ViewItem->loadTemplate( $tpl = NULL ).../HtmlView.php:230
160.16254596632include( '/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.0003397976{main}( ).../index.php:0
20.02931348368Joomla\CMS\Application\SiteApplication->execute( ).../index.php:49
30.02931348368Joomla\CMS\Application\SiteApplication->doExecute( ).../CMSApplication.php:196
40.12143056088Joomla\CMS\Application\SiteApplication->dispatch( $component = ??? ).../SiteApplication.php:233
50.12183080504Joomla\CMS\Component\ComponentHelper::renderComponent( $option = 'com_k2', $params = ??? ).../SiteApplication.php:194
60.12223135856Joomla\CMS\Component\ComponentHelper::executeComponent( $path = '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ).../ComponentHelper.php:377
70.12233152912require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php ).../ComponentHelper.php:402
80.12643383712K2ControllerItem->execute( $task = '' ).../k2.php:64
90.12643383712K2ControllerItem->display( $cachable = ???, $urlparams = ??? ).../BaseController.php:710
100.12983622232K2ControllerItem->display( $cachable = TRUE, $urlparams = ['id' => 'INT', 'print' => 'INT', 'lang' => 'CMD', 'Itemid' => 'INT', 'm' => 'INT', 'amp' => 'INT', 'tmpl' => 'CMD', 'template' => 'CMD'] ).../item.php:78
110.12983622232K2ControllerItem->display( $cachable = TRUE, $urlparams = ['id' => 'INT', 'print' => 'INT', 'lang' => 'CMD', 'Itemid' => 'INT', 'm' => 'INT', 'amp' => 'INT', 'tmpl' => 'CMD', 'template' => 'CMD'] ).../controller.php:19
120.13063645136Joomla\CMS\Cache\Controller\ViewController->get( $view = class K2ViewItem { public $document = class Joomla\CMS\Document\HtmlDocument { public $_links = [...]; public $_custom = [...]; public $template = NULL; public $baseurl = NULL; public $params = NULL; public $_file = NULL; protected $_template = ''; protected $_template_tags = [...]; protected $_caching = NULL; private $_html5 = NULL; public $title = 'add a user to the sudoers linux为用户添加sudo权限'; public $description = '&nbsp; 用sudo时提示&#34;xxx is not in the sudoers file. This incident will be reported.其中XXX是你的用户名,也就是你的用户名没有权限使用sudo,我们只要修改一下/etc/sudoers文件就行了。下面是修改方 法:...'; public $link = ''; public $base = 'https://www.shan.info/item/364-add-a-user-to-the-sudoers.html'; public $language = 'en-gb'; public $direction = 'ltr'; public $_generator = 'Joomla! - Open Source Content Management'; public $_mdate = ''; public $_tab = '\t'; public $_lineEnd = '\n'; public $_charset = 'utf-8'; public $_mime = 'text/html'; public $_namespace = ''; public $_profile = ''; public $_scripts = [...]; public $_script = [...]; protected $scriptOptions = [...]; public $_styleSheets = [...]; public $_style = [...]; public $_metaTags = [...]; public $_engine = NULL; public $_type = 'html'; protected $mediaVersion = '15dbf078d61dbbf76811992dd0143dd9' }; protected $_name = 'item'; protected $_models = ['itemlist' => class K2ModelItemlist { ... }, 'item' => class K2ModelItem { ... }]; protected $_basePath = '/var/www/vhosts/shan.info/httpdocs/components/com_k2'; protected $_defaultModel = 'item'; protected $_layout = 'item'; protected $_layoutExt = 'php'; protected $_layoutTemplate = '_'; protected $_path = ['template' => [...], 'helper' => [...]]; protected $_template = '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php'; protected $_output = NULL; protected $_escape = 'htmlspecialchars'; protected $_charset = 'UTF-8'; protected $_errors = []; public $baseurl = ''; public $addLink = NULL; public $inlineCommentsModeration = FALSE; public $item = class stdClass { public $id = '364'; public $title = 'add a user to the sudoers linux为用户添加sudo权限'; public $alias = 'add-a-user-to-the-sudoers'; public $catid = '49'; public $published = '1'; public $introtext = '<p>\r\n\t&nbsp;</p>\r\n<pre style="margin-top: 0px; margin-bottom: 10px; padding: 5px; border: 0px; font-size: 14px; vertical-align: baseline; background-color: rgb(224, 224, 224); overflow: auto; width: auto; max-height: 600px; font-family: \'Ubuntu Mono\', \'Ubuntu Beta Mono A\', Consolas, \'Bitstream Vera Sans Mono\', \'Courier New\', Courier, monospace; color: rgb(51, 51, 51); line-height: 17px;">\r\n</pre>\r\n<p>\r\n\t<span style="color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size'; public $fulltext = ''; public $video = NULL; public $gallery = NULL; public $extra_fields = NULL; public $extra_fields_search = ''; public $created = '2013-01-09 18:02:43'; public $created_by = '63'; public $created_by_alias = ''; public $checked_out = '63'; public $checked_out_time = '2013-01-09 18:06:02'; public $modified = '0000-00-00 00:00:00'; public $modified_by = '0'; public $publish_up = '2013-01-09 18:02:43'; public $publish_down = '0000-00-00 00:00:00'; public $trash = '0'; public $access = '1'; public $ordering = '23'; public $featured = '0'; public $featured_ordering = '0'; public $image_caption = ''; public $image_credits = ''; public $video_caption = ''; public $video_credits = ''; public $hits = '1755'; public $params = class Joomla\Registry\Registry { ... }; public $metadesc = ''; public $metadata = 'robots=\nauthor='; public $metakey = ''; public $plugins = ''; public $language = '*'; public $category = class TableK2Category { ... }; public $link = '/item/364-add-a-user-to-the-sudoers.html'; public $printLink = '/item/364-add-a-user-to-the-sudoers.html?tmpl=component&amp;print=1'; public $tags = [...]; public $imageXSmall = ''; public $imageSmall = ''; public $imageMedium = ''; public $imageLarge = ''; public $imageXLarge = ''; public $attachments = [...]; public $rawTitle = 'add a user to the sudoers linux为用户添加sudo权限'; public $author = class Joomla\CMS\User\User { ... }; public $videoType = 'allvideos'; public $text = '<p>\r\n\t&nbsp;</p>\r\n<pre style="margin-top: 0px; margin-bottom: 10px; padding: 5px; border: 0px; font-size: 14px; vertical-align: baseline; background-color: rgb(224, 224, 224); overflow: auto; width: auto; max-height: 600px; font-family: \'Ubuntu Mono\', \'Ubuntu Beta Mono A\', Consolas, \'Bitstream Vera Sans Mono\', \'Courier New\', Courier, monospace; color: rgb(51, 51, 51); line-height: 17px;">\r\n</pre>\r\n<p>\r\n\t<span style="color: rgb(69, 69, 69); font-family: tahoma, helvetica, arial; font-size'; public $event = class stdClass { ... }; public $jcfields = [...]; public $image = ''; public $imageWidth = '600'; public $comments = [...]; public $numOfComments = 0; public $nextLink = '/item/367-centos-6-epel.html'; public $nextTitle = 'centos 6 epel'; public $nextImageXSmall = ''; public $nextImageSmall = ''; public $nextImageMedium = ''; public $nextImageLarge = ''; public $nextImageXLarge = ''; public $previousLink = '/item/286-centos-memcached-php-5-2-17-ius-repo.html'; public $previousTitle = 'centos memcached php 5.2.17 ius repo'; public $previousImageXSmall = ''; public $previousImageSmall = ''; public $previousImageMedium = ''; public $previousImageLarge = ''; public $previousImageXLarge = ''; public $absoluteURL = 'https://www.shan.info/item/364-add-a-user-to-the-sudoers.html'; public $langTagForFB = 'en_GB'; public $langTagForTW = 'en-gb'; public $langTagForLI = 'en_GB'; public $sharinglink = 'https://www.shan.info/item/364-add-a-user-to-the-sudoers.html'; public $socialLink = 'https%3A%2F%2Fwww.shan.info%2Fitem%2F364-add-a-user-to-the-sudoers.html'; public $twitterURL = 'https://twitter.com/intent/tweet?text=add+a+user+to+the+sudoers+linux%E4%B8%BA%E7%94%A8%E6%88%B7%E6%B7%BB%E5%8A%A0sudo%E6%9D%83%E9%99%90&amp;url=https%3A%2F%2Fwww.shan.info%2Fitem%2F364-add-a-user-to-the-sudoers.html'; public $langTagForGP = ''; public $emailLink = '/component/mailto/?tmpl=component&amp;template=gk_publisher&amp;link=23c5d31d39398fd8492a4a4520bd1fde524bb975' }; public $user = class Joomla\CMS\User\User { protected $isRoot = FALSE; public $id = 0; public $name = NULL; public $username = NULL; public $email = NULL; public $password = NULL; public $password_clear = ''; public $block = NULL; public $sendEmail = 0; public $registerDate = NULL; public $lastvisitDate = NULL; public $activation = NULL; public $params = NULL; public $groups = [...]; public $guest = 1; public $lastResetTime = NULL; public $resetCount = NULL; public $requireReset = NULL; protected $_params = class Joomla\Registry\Registry { ... }; protected $_authGroups = NULL; protected $_authLevels = [...]; protected $_authActions = NULL; protected $_errorMsg = NULL; protected $userHelper = class Joomla\CMS\User\UserWrapper { ... }; protected $_errors = [...]; public $aid = 0; public $gid = 1 }; public $params = class Joomla\Registry\Registry { protected $data = class stdClass { ... }; protected $initialized = TRUE; public $separator = '.' }; public $pagination = class Joomla\CMS\Pagination\Pagination { public $limitstart = 0; public $limit = 10; public $total = 0; public $prefix = ''; public $pagesStart = 1; public $pagesStop = 0; public $pagesCurrent = 1; public $pagesTotal = 0; public $hideEmptyLimitstart = FALSE; protected $viewall = FALSE; protected $additionalUrlParams = [...]; protected $app = class Joomla\CMS\Application\SiteApplication { ... }; protected $data = NULL } }, $method = 'display', $id = ???, $wrkarounds = ??? ).../BaseController.php:663
130.13213731040K2ViewItem->display( $tpl = ??? ).../ViewController.php:102
140.16144394560K2ViewItem->display( $tpl = NULL ).../view.html.php:742
150.16144394560K2ViewItem->loadTemplate( $tpl = NULL ).../HtmlView.php:230
160.16254596632include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/item.php ).../HtmlView.php:701
back to top