centos:添加用戶


初步進入centos學習,配置用戶

1,創建用戶

創建用戶 hadoop

[root@master spark]# useradd hadoop
[root@master spark]#

2,創建密碼

[root@master spark]# passwd hadoop
Changing password for user hadoop.
New password: 
BAD PASSWORD: The password is shorter than 8 characters
Retype new password: 
passwd: all authentication tokens updated successfully.

3,用戶授權

創建賬戶必須授權,不然,個人用戶的權限只可以在本home下有權限,其他的必須有授權,一般需要root的權限
sudo的命令授權一般在sudoers里面
找到sudoer文件位置
看下文件的權限

[spark@master ~]$ sudoers
-bash: sudoers: command not found
[spark@master ~]$ whereis sudoers
sudoers: /etc/sudoers /etc/sudoers.d /usr/share/man/man5/sudoers.5.gz

只讀的文件,可以修改權限或者強行保存

[root@centos etc]# vi /etc/sudoers
## Allow root to run any commands anywher
root   ALL=(ALL) ALL #這個是新增的用戶 
hadoop ALL=(ALL) ALL  #這個是新增的用戶

用x!命令強制保存

或者修改文件權限

chmod -v u+w /etc/sudoers

配置完了,最好把權限收回

chmod -v u-w /etc/sudoers

到這里基本結束了。

可以用新用戶登陸了,使用sudo命令這塊

[hadoop@centos ~]$ sudo cat /etc/passwd
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

[sudo] password for hadoop:

 


免責聲明!

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



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