zoukankan      html  css  js  c++  java
  • Ubuntu10.10如何给用户添加sudo权限

    参考文献

    http://hi.baidu.com/xiboliya/blog/item/015ead864e041b2a67096eda.html

    正文

    Ubuntu-10.10系统安装过程中,系统会提示建立一个默认用户,比如用户名为:xuwei。这个默认用户具有一定的管理功能,即可以通过sudo命令执行root权限的操作。由于Ubuntu系统不允许通过root用户登录系统,所以这个默认用户即是实际意义上的管理员。现在的问题是:如果新建一个用户:hadoop,然后要将此用户设置为与xuwei相同的管理员用户。此问题有2种方式实现:

    1. 界面方式。用xuwei登录系统,通过选择菜单:系统->系统管理->用户和组,选择hadoop用户,更改账户类型为:管理员。然后重启电脑,用hadoop用户登录即可。
    2. 命令行方式。用xuwei登录系统,打开终端运行:
    sudo gedit /etc/sudoers  

    修改此配置文件,修改后的/etc/sudoers文件的内容如下,其中最后一行为添加的hadoop用户:

    # /etc/sudoers
    #
    # This file MUST be edited with the 'visudo' command as root.
    #
    # See the man page for details on how to write a sudoers file.
    #
    
    Defaults    env_reset
    
    # Host alias specification
    
    # User alias specification
    
    # Cmnd alias specification
    
    # User privilege specification
    root    ALL=(ALL) ALL
    
    # Allow members of group sudo to execute any command
    # (Note that later entries override this, so you might need to move
    # it further down)
    %sudo ALL=(ALL) ALL
    #
    #includedir /etc/sudoers.d
    
    # Members of the admin group may gain root privileges
    %admin ALL=(ALL) ALL
    hadoop ALL=(ALL) ALL

    然后重启电脑,用hadoop用户登录即可。

    PS:创建hadoop用户并将其添加到hadoop组中去到方法

    首先创建hadoop组,命令如下:

    sudo addgroup hadoop 

    创建用户并并将其添加到刚才创建到hadoop组中

    sudo adduser --ingroup hadoop hadoop  

    执行这个命令完以后会提示我们输入密码。密码输入两次并相同则创建用户成功。

    如果我们要是hadoop用户能够使用sudo命令,那么就按照上面描述进行操作。我是使用第二种方法。

     

     

    作者:xwdreamer
    欢迎任何形式的转载,但请务必注明出处。
    分享到:
  • 相关阅读:
    列表页无限滚动翻页组件--解决性能问题
    UI组件化介绍
    js请求数据的例子
    移动端bug和优化
    利用字符串路径获取对象集合的值
    n个骰子的和,组成数字m的可能
    算法-回形路径
    学习python-跨平台获取键盘事件
    获取数组中多个相加等于0的一组数字 javascript
    一个矩阵 JavaScript
  • 原文地址:https://www.cnblogs.com/xwdreamer/p/2510832.html
Copyright © 2011-2022 走看看