日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
linux怎么給普通用戶提供root用戶的權(quán)限-創(chuàng)新互聯(lián)

本篇內(nèi)容主要講解“l(fā)inux怎么給普通用戶提供root用戶的權(quán)限”,感興趣的朋友不妨來(lái)看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓小編來(lái)帶大家學(xué)習(xí)“l(fā)inux怎么給普通用戶提供root用戶的權(quán)限”吧!

在鋼城等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場(chǎng)前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供網(wǎng)站建設(shè)、網(wǎng)站制作 網(wǎng)站設(shè)計(jì)制作按需定制,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),品牌網(wǎng)站建設(shè),網(wǎng)絡(luò)營(yíng)銷(xiāo)推廣,外貿(mào)網(wǎng)站建設(shè),鋼城網(wǎng)站建設(shè)費(fèi)用合理。

sudo 的特點(diǎn)

限制用戶執(zhí)行指定的命令
記錄用戶執(zhí)行的每一條命令
配置文件(/etc/sudoers)提供集中的用戶管理、權(quán)限與主機(jī)等參數(shù)
驗(yàn)證密碼的后5分鐘內(nèi)(默認(rèn)值)無(wú)須再讓用戶再次驗(yàn)證密碼

實(shí)戰(zhàn)演練

環(huán)境:Red Hat Enterprise Linux Server release 7.3

1. 測(cè)試普通用戶能否刪除 root 用戶創(chuàng)建的文件

[root@localhost ~]# mkdir /test
[root@localhost ~]# cd /test
[root@localhost test]# touch test.txt
[root@localhost test]# mkdir test.dir
[root@localhost test]# ll
total 0
drwxr-xr-x. 2 root root 6 Jul 18 02:19 test.dir
-rw-r--r--. 1 root root 0 Jul 18 02:19 test.txt
[root@localhost test]# id test
uid=1004(test) gid=1005(test) groups=1005(test)
[root@localhost test]# su - test
Last login: Thu Jul 18 02:17:11 EDT 2019 on pts/0
[test@localhost ~]$ cd /test
[test@localhost test]$ ll
total 0
drwxr-xr-x. 2 root root 6 Jul 18 02:19 test.dir
-rw-r--r--. 1 root root 0 Jul 18 02:19 test.txt
[test@localhost test]$ rm -rf test.dir/
rm: cannot remove ‘test.dir/’: Permission denied
[test@localhost test]$ rm -rf test.txt 
rm: cannot remove ‘test.txt’: Permission denied
[test@localhost test]$ ll
total 0
drwxr-xr-x. 2 root root 6 Jul 18 02:19 test.dir
-rw-r--r--. 1 root root 0 Jul 18 02:19 test.txt

2. 用 visudo 命令配置 sudo

[root@localhost ~]# visudo
# 在 /etc/sudoers 配置文件中 root    ALL=(ALL)       ALL 這一行下面加入 test    ALL=(ALL)       ALL
[root@localhost ~]# cat /etc/sudoers | grep ALL
Defaults    env_keep += "LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY"
root    ALL=(ALL)       ALL
test    ALL=(ALL)       ALL
# %sys ALL = NETWORKING, SOFTWARE, SERVICES, STORAGE, DELEGATING, PROCESSES, LOCATE, DRIVERS
%wheel  ALL=(ALL)       ALL
# %wheel        ALL=(ALL)       NOPASSWD: ALL
%wheel  ALL=(ALL)       NOPASSWD: ALL
# %users  ALL=/sbin/mount /mnt/cdrom, /sbin/umount /mnt/cdrom

3. 普通用戶結(jié)合 sudo 刪除 root 用戶的文件

[root@localhost ~]# echo "Jaking" | passwd --stdin test
Changing password for user test.
passwd: all authentication tokens updated successfully.
[root@localhost ~]# su - test
Last login: Thu Jul 18 02:34:50 EDT 2019 on pts/0
[test@localhost ~]$ cd /test/
[test@localhost test]$ ll
total 0
drwxr-xr-x. 2 root root 6 Jul 18 02:19 test.dir
-rw-r--r--. 1 root root 0 Jul 18 02:19 test.txt
[test@localhost test]$ rm -rf test.dir/
rm: cannot remove ‘test.dir/’: Permission denied
[test@localhost test]$ rm -rf test.txt 
rm: cannot remove ‘test.txt’: Permission denied
[test@localhost test]$ sudo rm -rf test.dir/
[sudo] password for test: 
[test@localhost test]$ ll
total 0
-rw-r--r--. 1 root root 0 Jul 18 02:19 test.txt
[test@localhost test]$ sudo rm -rf test.txt 
[test@localhost test]$ ll
total 0

4. sudo 免密配置

[test@localhost test]$ sudo cat /etc/shadow
[sudo] password for test: 
root:$6$YZrm6scxO5zzICbR$fOzORb.0Ib9POZzJmrnzOGDqfFySp8X.9p5QpcpnJXWHIJvZcFpXQONyNigwrZbhXtyfnFn5F1mJsdkXS3jEF/::0:99999:7:::
bin:*:16925:0:99999:7:::
daemon:*:16925:0:99999:7:::
adm:*:16925:0:99999:7:::
***省略部分輸出信息***
[test@localhost test]$ id test2
uid=1006(test2) gid=1007(test2) groups=1007(test2)
[root@localhost ~]# visudo
# 在 /etc/sudoers 配置文件中 %wheel  ALL=(ALL)       NOPASSWD: ALL 這一行的下面 加入test ALL=(ALL)       NOPASSWD: ALL
[root@localhost ~]# cat /etc/sudoers | grep NOPASSWD
# %wheel        ALL=(ALL)       NOPASSWD: ALL
%wheel  ALL=(ALL)       NOPASSWD: ALL
test ALL=(ALL)       NOPASSWD: ALL
[test@localhost ~]$ sudo cat /etc/shadow
# 用普通用戶查看 /etc/shadow 文件已經(jīng)不需要再輸入當(dāng)前登錄用戶的密碼
root:$6$YZrm6scxO5zzICbR$fOzORb.0Ib9POZzJmrnzOGDqfFySp8X.9p5QpcpnJXWHIJvZcFpXQONyNigwrZbhXtyfnFn5F1mJsdkXS3jEF/::0:99999:7:::
bin:*:16925:0:99999:7:::
daemon:*:16925:0:99999:7:::
adm:*:16925:0:99999:7:::
***省略部分輸出信息***

5. 配置 sudo 的部分權(quán)限

[root@localhost ~]# cd /tmp
[root@localhost tmp]# rm -rf *
[root@localhost tmp]# ll
total 0
[root@localhost tmp]# touch file
[root@localhost tmp]# mkdir dir
[root@localhost tmp]# ll
total 0
drwxr-xr-x. 2 root root 6 Jul 18 03:01 dir
-rw-r--r--. 1 root root 0 Jul 18 03:01 file
[root@localhost tmp]# whereis cat
cat: /usr/bin/cat /usr/share/man/man1/cat.1.gz
[root@localhost tmp]# visudo
# 把 /etc/sudoers 配置文件中的 test    ALL=(ALL)       ALL 改為 test    ALL=(ALL)       /usr/bin/cat
[root@localhost ~]# cat /etc/sudoers | grep cat
## Updating the locate database
# Defaults specification
# Preserving HOME has security implications since many programs
test    ALL=(ALL)       /usr/bin/cat
[root@localhost ~]# su - test
Last login: Thu Jul 18 03:06:55 EDT 2019 on pts/0
[test@localhost ~]$ sudo cat /etc/shadow
# 給 test 用戶配置了查看權(quán)限
root:$6$YZrm6scxO5zzICbR$fOzORb.0Ib9POZzJmrnzOGDqfFySp8X.9p5QpcpnJXWHIJvZcFpXQONyNigwrZbhXtyfnFn5F1mJsdkXS3jEF/::0:99999:7:::
bin:*:16925:0:99999:7:::
daemon:*:16925:0:99999:7:::
adm:*:16925:0:99999:7:::
***省略部分輸出信息***
[test@localhost ~]$ cd /tmp
[test@localhost tmp]$ ll
total 0
drwxr-xr-x. 2 root root 6 Jul 18 03:06 dir
-rw-r--r--. 1 root root 0 Jul 18 03:01 file
[test@localhost tmp]$ rm -rf dir
# test 用戶已經(jīng)沒(méi)有了刪除權(quán)限
rm: cannot remove ‘dir’: Permission denied
[test@localhost tmp]$ rm -rf file 
# test 用戶已經(jīng)沒(méi)有了刪除權(quán)限
rm: cannot remove ‘file’: Permission denied
[test@localhost tmp]$ ll
total 0
drwxr-xr-x. 2 root root 6 Jul 18 03:06 dir
-rw-r--r--. 1 root root 0 Jul 18 03:01 file

到此,相信大家對(duì)“l(fā)inux怎么給普通用戶提供root用戶的權(quán)限”有了更深的了解,不妨來(lái)實(shí)際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!


新聞標(biāo)題:linux怎么給普通用戶提供root用戶的權(quán)限-創(chuàng)新互聯(lián)
鏈接分享:http://www.dlmjj.cn/article/dhdjce.html