zoukankan      html  css  js  c++  java
  • Linux中sudo的用法

    在linux中的用户只有2种:root和非root。而非root即普通用户的权限非常低,基本处理自己的home目录,其他好多地方连查看的权利也没有,更不要说安装软件了。

    为了避免来回切换root,linux加入了sudo命令,即:可以临时切换的root来执行一些系统命令,用完之后,在返回普通用户,这样既避免长期使用root带来的安全风险,

    又有效的减少了切换root的频率。

    1、sudo命令的配置主配置文件:/etc/sudoers,不过,系统文档推荐的做法,不是直接修改/etc/sudoers文件,而是将修改写在/etc/sudoers.d/目录下的文件中。

    任何在/etc/sudoers.d/目录下,不以~号结尾的文件和不包含.号的文件,都会被解析成/etc/sudoers的内容。另外要注意:如果使用这种方式修改sudoers,

    需要在/etc/sudoers文件的最后行,加上#includedir /etc/sudoers.d语句(默认已有)。

    注意了,这里的指令#includedir是一个整体, 前面的#号不能丢,也不能在#号后有空格。并且,尽可能使用visudo来编辑sudoers, 因为有相关的错误识别机制。

    相关文档:

    # This will cause sudo to read and parse any files in the /etc/sudoers.d
    # directory that do not end in '~' or contain a '.' character.

    # Note that there must be at least one file in the sudoers.d directory (this
    # one will do), and all files in this directory should be mode 0440.

    # Note also, that because sudoers contents can vary widely, no attempt is
    # made to add this directive to existing sudoers files on upgrade.

    # Finally, please note that using the visudo command is the recommended way
    # to update sudoers content, since it protects against many failure modes.

    2、具体的配置命令

  • 相关阅读:
    Eclipse中properties文件中文显示编码、乱码问题
    Eclipse中安装yml插件( YEdit )
    Java中如何返回Json数组
    ASIFormDataRequest 登录
    Safari里使用JsonView
    beginUpdates和endUpdates
    svn log 不显示日志的问题
    svn代码回滚命令
    Tomcat: localhost:8080 提示404
    android定时三种方式
  • 原文地址:https://www.cnblogs.com/litifeng/p/6949543.html
Copyright © 2011-2022 走看看