Linux添加root权限:is not in the sudoers file解决方法

这篇具有很好参考价值的文章主要介绍了Linux添加root权限:is not in the sudoers file解决方法。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

Linux添加root权限:is not in the sudoers file解决方法

当我们使用sudo命令切换用户的时候可能会遇到提示以下错误:用户名 is not in the sudoers file.

原因

当前的用户没有加入到sudo的配置文件里

解决方案

#切换到root用户
su
#编辑配置文件
vim /etc/sudoers
#增加配置, 在打开的配置文件中,找到root ALL=(ALL) ALL, 在下面添加一行
#其中xxx是你要加入的用户名称
xxx ALL=(ALL) ALL

文件保存报错

使用:wq保存/etc/sudoers文件报错(不能保存只读文件):Linux:readonly option is set (add ! to override)
直接使用:wq!强制保存。

:wq和:wq!的区别如下:

有些文件设置了只读,一般不是修改文件的,但是如果你是文件的owner或者root的话,通过:wq!还是能保存文件退出
如果文件设置为只读了的话,用 :wq命令是不能保存并退出的,但是最高权限者可通过wq!来进行文件的保存并退出文件。
已设定选项 ‘readonly’ (请加 ! 强制执行)
文件所有者通过 wq! 可以保存只读文件
!是强制执行
如果不带!碰上只读文件,会给提示会是只读文件,带了!忽略只读强制写入文章来源地址https://www.toymoban.com/news/detail-636896.html

到了这里,关于Linux添加root权限:is not in the sudoers file解决方法的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包赞助服务器费用

相关文章

  • vite4生产环境打包报错NODE_ENV=production is not supported in the .env file.

    vite4生产环境打包报错NODE_ENV=production is not supported in the .env file.

    vue3+vite4生产环境production打包报错: 大致意思就是: NODE_ENV=.ENV文件中不支持生产。仅支持NODE_ENV=开发来创建项目的开发构建。如果需要设置process.env.NODE_env,则可以在Vite配置中进行设置。 ** ** 如果有警告 那就把vite.config.js里面的minify换成:terser(别忘记install下载了)

    2024年02月11日
    浏览(48)
  • Java异常 #Number of lines annotated by Git is not equal to number of lines in the file, check file …

    Java异常 #Number of lines annotated by Git is not equal to number of lines in the file, check file …

    在项目中某个 java 文件左边栏右键查看代码版本履历(Annotate)时无法显示,IDEA 提示:Number of lines annotated by Git is not equal to number of lines in the file, check file encoding and line separators.   这个问题涉及到不同操作系统下文本文件的换行符差异引起的。在不同操作系统中,文本文件的

    2024年02月03日
    浏览(28)
  • git pull error: Pulling is not possible because you have unmerged files.hint: Fix them up in the ...

    git pull error: Pulling is not possible because you have unmerged files.hint: Fix them up in the ...

    git pull 报错如下 解决方案如下 PS F:jyjuyi_dataplat_web git pull error: Pulling is not possible because you have unmerged files. 错误:无法提取,因为您有未合并的文件。 hint: Fix them up in the work tree, and then use \\\'git add/rm file\\\' 提示:在工作树中修改它们,然后使用\\\'git add/rm \\\' hint: as appropriate to mark reso

    2024年01月16日
    浏览(57)
  • cannot be resolved to absolute file path because it does not reside in the file system 问题解决

    cannot be resolved to absolute file path because it does not reside in the file system 问题解决

    在Springboot中利用Resource来获取文件并在前端返回该文件, 本地测试正常, 打包到远程报错: cannot be resolved to absolute file path because it does not reside in the file system 紧接上一个问题: 项目打包成 jar 后包无法读取src/main/resources下文件, 在Springboot打包之后, 无法读取到jar包内的文件, 因此

    2023年04月18日
    浏览(15)
  • Sourcetree git 出现 The server‘s host key is not cached in the registry问题的解决办法

    省流: 参考博文:https://blog.csdn.net/sryan/article/details/50717528 Sourcetree会自带plink,用命令行切换到plink.exe所在路径,并执行plink git@github.com 命令,根据提示输入y 回车,问题就解决了。本质上是plink问玩家要y还是n,但是在Sourcetree的错误提示那里不能输入。 问题描述: 这几天用

    2024年02月03日
    浏览(21)
  • Vite解决报错(Top-level await is not available in the configured target environment)

    Vite解决报错(Top-level await is not available in the configured target environment)

    项目在用vite打包时报错 报错信息:“Top-level await is not available in the configured target environmen“ 翻译 “顶级等待在配置的目标环境中不可用” 解决问题 npm安装vite-plugin-top-level-await插件 配置vite.config.js文件 之后在plugins中添加topLevelAwait方法 最后重新打包即可

    2024年02月10日
    浏览(10)
  • 解决错误:pip is configured with locations that require TLS/SSL,the ssl module in Python is not available

    解决错误:pip is configured with locations that require TLS/SSL,the ssl module in Python is not available。 pip安装包出现错误类似如下: WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available. Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting protobuf=4.25.2 (fr

    2024年02月19日
    浏览(14)
  • is a JavaScript file. Did you mean to enable the ‘allowJs‘ option? The file is in the program beca

    is a JavaScript file. Did you mean to enable the ‘allowJs‘ option? The file is in the program beca

    error TS6504: File ‘/Users/mac/Desktop/eezi/eezi-epc/src/views/home/index.vue.jsx’ is a JavaScript file. Did you mean to enable the ‘allowJs’ option?The file is in the program because: Root file specified for compilation 加上即可

    2024年02月11日
    浏览(8)
  • linux里root用户权限下chmod修改文件却报错:Operation not permitted的解决方法

    linux里root用户权限下chmod修改文件却报错:Operation not permitted的解决方法

    root权限。在家目录里有个test的文件夹,但是这里想要用chmod命令修改该文件夹的权限,却报错 chmod: changing permissions of ‘test’: Operation not permitted 可以通过执行以下命令来检查文件系统是否已挂载为只读模式: mount | grep ’ / ’ 该命令将列出根文件系统的详细信息,包括挂载

    2024年04月24日
    浏览(43)
  • DOCKER权限设置:LINUX新增用户添加ROOT权限

    DOCKER权限设置:LINUX新增用户添加ROOT权限

    一、首先在LINUX下创建新用户 二、为用户添加ROOT权限 如果,在修改/etc/sudoers 文件,你该错误了,会导致使用不了sudo命令,使用vim也打不开该文件了;如下提示:   解决方式 :执行下面的命令 三、为非ROOT用户添加DOCKER执行权限 方式一:创建docker组   方式二:直接修改  

    2024年02月11日
    浏览(15)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包