Ubuntu-10.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命令,那么就按照上面描述進行操作。我是使用第二種方法。

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM