新聞中心
前言
筆記本安裝了一個centos,想要讓別人也可以登錄訪問,用自己的賬號確實不太好,于是準(zhǔn)備新建一個用戶給他。

創(chuàng)新互聯(lián)公司是一家專業(yè)的成都網(wǎng)站建設(shè)公司,我們專注成都網(wǎng)站制作、做網(wǎng)站、外貿(mào)營銷網(wǎng)站建設(shè)、網(wǎng)絡(luò)營銷、企業(yè)網(wǎng)站建設(shè),賣友情鏈接,1元廣告為企業(yè)客戶提供一站式建站解決方案,能帶給客戶新的互聯(lián)網(wǎng)理念。從網(wǎng)站結(jié)構(gòu)的規(guī)劃UI設(shè)計到用戶體驗提高,創(chuàng)新互聯(lián)力求做到盡善盡美。
創(chuàng)建新用戶
[root@localhost ~]# adduser linuxidc
為這個用戶初始化密碼,linux會判斷密碼復(fù)雜度,不過可以強行忽略:
[root@localhost ~]# passwd linuxidc
更改用戶 zhangbiao 的密碼 。
新的 密碼:
無效的密碼: 密碼未通過字典檢查 - 過于簡單化/系統(tǒng)化
重新輸入新的 密碼:
passwd:所有的身份驗證令牌已經(jīng)成功更新。
授權(quán)
個人用戶的權(quán)限只可以在本home下有完整權(quán)限,其他目錄要看別人授權(quán)。而經(jīng)常需要root用戶的權(quán)限,這時候sudo可以化身為root來操作。我記得我曾經(jīng)sudo創(chuàng)建了文件,然后發(fā)現(xiàn)自己并沒有讀寫權(quán)限,因為查看權(quán)限是root創(chuàng)建的。
新創(chuàng)建的用戶并不能使用sudo命令,需要給他添加授權(quán)。
sudo命令的授權(quán)管理是在sudoers文件里的??梢钥纯磗udoers:
[root@localhost ~]# sudoers
bash: sudoers: 未找到命令...
[root@localhost ~]# whereis sudoers
sudoers: /etc/sudoers /etc/sudoers.d /usr/libexec/sudoers.so /usr/share/man/man5/sudoers.5.gz
找到這個文件位置之后再查看權(quán)限:
[root@localhost ~]# ls -l /etc/sudoers
-r--r----- 1 root root 4251 9月 25 15:08 /etc/sudoers
是的,只有只讀的權(quán)限,如果想要修改的話,需要先添加w權(quán)限:
[root@localhost ~]# chmod -v u+w /etc/sudoers
mode of "/etc/sudoers" changed from 0440 (r--r-----) to 0640 (rw-r-----)
然后就可以添加內(nèi)容了,在下面的一行下追加新增的用戶:
[root@localhost ~]# vim /etc/sudoers
## Allow root to run any commands anywher
root ALL=(ALL) ALL
linuxidc ALL=(ALL) ALL #這個是新增的用戶
wq保存退出,這時候要記得將寫權(quán)限收回:
[root@localhost ~]# chmod -v u-w /etc/sudoers
mode of "/etc/sudoers" changed from 0640 (rw-r-----) to 0440 (r--r-----)
這時候使用新用戶登錄,使用sudo:
[linuxidc@localhost ~]$ sudo cat /etc/passwd
[sudo] password for linuxidc:
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.
第一次使用會提示你,你已經(jīng)化身超人,身負(fù)責(zé)任。而且需要輸入密碼才可以下一步。如果不想需要輸入密碼怎么辦,將最后一個ALL修改成NOPASSWD: ALL。
網(wǎng)站題目:CentOS7中添加一個新用戶并授權(quán)
瀏覽地址:http://m.fisionsoft.com.cn/article/cdoehhc.html


咨詢
建站咨詢
