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





    Add, Remove, and List Sudo Users in a WSL Linux Distro in Windows 10 OPTION ONE Add, Remove, and List Sudo Users in a WSL Linux Distro in Windows 10
    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.

    Name:  List_sudo_users_in_WSL_distro-1.png
Views: 133
Size:  6.5 KB
    Name:  List_sudo_users_in_WSL_distro-2.png
Views: 128
Size:  6.1 KB
    Name:  List_sudo_users_in_WSL_distro-3.png
Views: 128
Size:  6.3 KB






    Add, Remove, and List Sudo Users in a WSL Linux Distro in Windows 10 OPTION TWO Add, Remove, and List Sudo Users in a WSL Linux Distro in Windows 10
    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

    Name:  Root_add_sudo_user_in_WSL_distro.png
Views: 134
Size:  6.4 KB






    Add, Remove, and List Sudo Users in a WSL Linux Distro in Windows 10 OPTION THREE Add, Remove, and List Sudo Users in a WSL Linux Distro in Windows 10
    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.

    Name:  Sudo_add_sudo_user_in_WSL_distro.png
Views: 131
Size:  6.7 KB






    Add, Remove, and List Sudo Users in a WSL Linux Distro in Windows 10 OPTION FOUR Add, Remove, and List Sudo Users in a WSL Linux Distro in Windows 10
    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

    Name:  Root_remove_sudo_user_in_WSL_distro.png
Views: 126
Size:  6.3 KB






    Add, Remove, and List Sudo Users in a WSL Linux Distro in Windows 10 OPTION FIVE Add, Remove, and List Sudo Users in a WSL Linux Distro in Windows 10
    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.

    Name:  Sudo_remove_sudo_user_in_WSL_distro.png
Views: 125
Size:  6.7 KB


    That's it,
    Shawn


    Related Tutorials



  1. ThrashZone's Avatar
    Posts : 4,354
    3-Win-7Prox64 2-Win10Prox64
       #1

    Hi,
    The irony a tutorial of Linux
      My ComputersSystem Spec


 

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 Threads
How to List 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...
How to Change User Password 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...
How to Reset User Password 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...
How to Export and Import 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...
Source: Open Sourcing a WSL Sample for Linux Distribution Maintainers and Sideloading Custom Linux Distributions Windows Command Line Tools For Developers
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 07:49.
Find Us