菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
251
0

How can I add a new user as sudoer using the command line?

原创
05/13 14:22
阅读数 360269

标签:des   com   http   code   ext   type   user   set   ble   log   line   

Two ways to use sudo command for a standard user account:

First,

If you want to use sudo command for a standard user account, then you need to add this account to /etc/sudoers file. Use the following steps to add your desired user account to /etc/sudoers file:

  • login as administration : i.e.   su – adminuser
  • type sudo visudo
  • Find out the following

# User privilege specification
root ALL=(ALL) ALL
%admin ALL=(ALL) ALL

  • Add your user account below “root ALL=(ALL) ALL”.  For example:

# User privilege specification
root ALL=(ALL) ALL
yourusername ALL=(ALL) ALL
%admin ALL=(ALL) ALL

 

    • Save your file (:wq), and now you will be able to use sudo command for your username.

Second(Recommended),

 

Just add the user to the sudo group:

sudo adduser <username> sudo

The change will take effect the next time the user logs in.

This works because /etc/sudoers is pre-configured to grant permissions to all members of this group (You should not have to make any changes to this):

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

As long as you have access to a user that is in the same groups as your "original" user, you can delete the old one.


Realistically, there are also other groups your new user should be a member of. If you set the Account type of a user to Administrator in Users Settings, it will be placed in at least all of these groups:

adm sudo lpadmin sambashare

Because your system configuration may vary, I suggest taking a look at the output of groups <username> to see what groups are normally in use.

How can I add a new user as sudoer using the command line?,码迷,mamicode.com

How can I add a new user as sudoer using the command line?

发表评论

0/200
251 点赞
0 评论
收藏
为你推荐 换一批