zoukankan      html  css  js  c++  java
  • How can I add a new user as sudoer using the command 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.

  • 相关阅读:
    学点 C 语言(40): 函数 多参函数
    存取 ListBox 列表 回复 "徐强" 的问题
    博客园RSS订阅汇总
    博客园电子期刊2012年2月刊发布啦
    上周热点回顾(3.53.11)
    博客园电子期刊2012年3月刊发布啦
    上周热点回顾(3.264.1)
    上周热点回顾(3.193.25)
    上周热点回顾(4.24.8)
    上周热点回顾(2.273.4)
  • 原文地址:https://www.cnblogs.com/rosepotato/p/3695254.html
Copyright © 2011-2022 走看看