官术网_书友最值得收藏!

Letting users run as other users

In the following line, (ALL) means that Sylvester can run the systemctl commands as any user:

sylvester     ALL=(ALL) /usr/bin/systemctl status sshd, /usr/bin/systemctl restart sshd

This effectively gives Sylvester root privileges for these commands because the root user is definitely any user. You could, if desired, change that (ALL) to (root) in order to specify that Sylvester can only run these commands as the root user:

sylvester     ALL=(root) /usr/bin/systemctl status sshd, /usr/bin/systemctl restart sshd

Okay, there's probably not much point in that because nothing changes. Sylvester had root privileges for these systemctl commands before, and he still has them now. But, there are more practical uses for this feature. Let's say that Vicky is a database admin, and you want her to run as the database user:

vicky    ALL=(database)    /usr/local/sbin/some_database_script.sh

Vicky could then run the command as the database user by entering the following code:

sudo -u database some_database_script.sh

This is one of those features that you might not use that often, but keep it in mind anyway. You never know when it might come in handy.

Okay, this wraps it up for our discussion of sudo. Let's now turn our attention to ensuring the security of our regular users.

主站蜘蛛池模板: 读书| 长子县| 濉溪县| 屏南县| 磐安县| 文化| 金寨县| 海丰县| 都昌县| 互助| 法库县| 西平县| 辛集市| 贵定县| 汾西县| 新兴县| 米林县| 蒲城县| 屏东市| 屏边| 德惠市| 鄂伦春自治旗| 陈巴尔虎旗| 南投县| 茂名市| 灌云县| 全州县| 如东县| 文化| 宁陕县| 宝坻区| 丹江口市| 大田县| 翁牛特旗| 安国市| 二连浩特市| 阿图什市| 蓝田县| 海安县| 比如县| 瓮安县|