Add, Remove, and List Sudo Users in a WSL Linux Distro in Windows 10  

    Add, Remove, and List Sudo Users in a WSL Linux Distro in Windows 10

    Add, Remove, and List Sudo Users in a WSL Linux Distro in Windows 10

    How to Add, Remove, and List Sudo Users in Windows Subsystem for Linux (WSL) Distro in Windows 10
    Published by Category: Apps & Features
    07 Mar 2019
    Designer Media Ltd

    How to Add, Remove, and List Sudo Users in Windows Subsystem for Linux (WSL) Distro in Windows 10


    The Windows Subsystem for Linux (WSL) is a new Windows 10 feature that enables you to run native Linux command-line tools directly on Windows, alongside your traditional Windows desktop and modern store apps.

    When you have Windows Subsystem for Linux (WSL) enabled, you can install WSL distro apps from the Microsoft Store, and export and import WSL distros.

    The first time a newly installed WSL distro runs, a Console window will open, and you'll be asked to wait for a minute or two for the installation to complete.

    Once installation is complete, you will be prompted to create a new user account (and its password).

    Creating your Linux user is the first step in setting up a new Linux distribution on WSL. The first user account you create is automatically configured with a few special attributes:
    1. It is your default user -- it signs-in automatically on launch.
    2. It is Linux administrator (a member of the sudo group) by default.

    Each Linux distribution running on the Windows Subsystem for Linux has its own Linux user accounts and passwords. You will have to configure a Linux user account any time you add a distribution, reinstall, or reset. Linux user accounts are not only independent per distribution, they are also independent from your Windows 10 user account.

    When you add a user to a WSL distro, this new user will not be a member of the sudo (aka: administrator) group by default.

    This tutorial will show you how to add, remove, and list users of the sudo group in a Windows Subsystem for Linux (WSL) distro in Windows 10.


     CONTENTS:

    • Option One: List All Sudo Users in a WSL Distro
    • Option Two: Add User to Sudo Group in a WSL Distro while signed in as Root
    • Option Three: Add User to Sudo Group in a WSL Distro while signed in as a Sudu User
    • Option Four: Remove User from Sudo Group in a WSL Distro while signed in as Root
    • Option Five: Remove User from Sudo Group in a WSL Distro while signed in as a Sudu User





    OPTION ONE

    List All Sudo Users in a WSL Distro


    1. Open the WSL distro (ex: "Ubuntu") you want to list all users that are currently a member of the sudo group in this WSL distro.

    2. Copy and paste either command below into the WSL distro console, and press Enter. (see screenshots below)

    grep '^sudo:.*$' /etc/group | cut -d: -f4

    OR

    getent group sudo | cut -d: -f4

    OR

    grep -Po '^sudo.+:\K.*$' /etc/group

    3. You will now see a list of all users that are currently a member of the sudo group in this WSL distro. Each user will be separated by a comma.

    You can compare this list of sudo users to the list of all users to see which users are not currently a member of the sudo group.

    Add, Remove, and List Sudo Users in a WSL Linux Distro in Windows 10-list_sudo_users_in_wsl_distro-1.png
    Add, Remove, and List Sudo Users in a WSL Linux Distro in Windows 10-list_sudo_users_in_wsl_distro-2.png
    Add, Remove, and List Sudo Users in a WSL Linux Distro in Windows 10-list_sudo_users_in_wsl_distro-3.png






    OPTION TWO

    Add User to Sudo Group in a WSL Distro while signed in as Root


    1. Open the WSL distro (ex: "Ubuntu") you want to add a user to the sudo group for this WSL distro.

    2. Type the command below into the WSL distro console, and press Enter. (see screenshot below)

    gpasswd -a <username> sudo

    Substitute <username> in the command above with the actual user (ex: "brink2") you want to add as a member of the sudo group for this WSL distro.

    For example: gpasswd -a brink2 sudo

    Add, Remove, and List Sudo Users in a WSL Linux Distro in Windows 10-root_add_sudo_user_in_wsl_distro.png






    OPTION THREE

    Add User to Sudo Group in a WSL Distro while signed in as a Sudu User


    1. Open the WSL distro (ex: "Ubuntu") you want to add a user to the sudo group for this WSL distro.

    2. Type the command below into the WSL distro console, and press Enter. (see screenshot below)

    sudu gpasswd -a <username> sudo

    Substitute <username> in the command above with the actual user (ex: "brink2") you want to add as a member of the sudo group for this WSL distro.

    For example: sudu gpasswd -a brink2 sudo

    3. When prompted, enter the password of the currently signed in sudo user (ex: "brink"), and press Enter.

    This will not be the password of the user (ex: "brink2") you want to add as a member of the sudo group.

    Add, Remove, and List Sudo Users in a WSL Linux Distro in Windows 10-sudo_add_sudo_user_in_wsl_distro.png






    OPTION FOUR

    Remove User from Sudo Group in a WSL Distro while signed in as Root


    1. Open the WSL distro (ex: "Ubuntu") you want to remove a user from the sudo group for this WSL distro.

    2. Type the command below into the WSL distro console, and press Enter. (see screenshot below)

    gpasswd -d <username> sudo

    Substitute <username> in the command above with the actual user (ex: "brink2") you want to remove as a member of the sudo group for this WSL distro.

    For example: gpasswd -d brink2 sudo

    Add, Remove, and List Sudo Users in a WSL Linux Distro in Windows 10-root_remove_sudo_user_in_wsl_distro.png






    OPTION FIVE

    Remove User from Sudo Group in a WSL Distro while signed in as a Sudu User


    1. Open the WSL distro (ex: "Ubuntu") you want to remove a user from the sudo group for this WSL distro.

    2. Type the command below into the WSL distro console, and press Enter. (see screenshot below)

    sudu gpasswd -d <username> sudo

    Substitute <username> in the command above with the actual user (ex: "brink2") you want to remove as a member of the sudo group for this WSL distro.

    For example: sudu gpasswd -d brink2 sudo

    3. When prompted, enter the password of the currently signed in sudo user (ex: "brink"), and press Enter.

    This will not be the password of the user (ex: "brink2") you want to remove as a member of the sudo group.

    Add, Remove, and List Sudo Users in a WSL Linux Distro in Windows 10-sudo_remove_sudo_user_in_wsl_distro.png


    That's it,
    Shawn


    Related Tutorials






  1. Posts : 7,724
    3-Win-7Prox64 3-Win10Prox64 3-LinuxMint20.2
       #1

    Hi,
    The irony a tutorial of Linux
      My Computers


 

Tutorial Categories

Add, Remove, and List Sudo Users in a WSL Linux Distro in Windows 10 Tutorial Index Network & Sharing Instalation and Upgrade Browsers and Email General Tips Gaming Customization Apps and Features Virtualization BSOD System Security User Accounts Hardware and Drivers Updates and Activation Backup and Restore Performance and Maintenance Mixed Reality Phone


  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 22:15.
Find Us




Windows 10 Forums