2

in linux how can I change from being a root user to a just plain user?

When I boot into bash on Windows 10 I now see:

"root@STANSTOY:/home/wojowhisky#"

how do I get it to boot to:

"wojowhiskey@STANSTOY:~$"?

3 Answers 3

2

To switch to a user in Linux:

su - wojowhiskey

To make your user a sudoer:

sudo visudo

And then add or edit the following line:

wojowhiskey ALL=(ALL) ALL
6
  • Yes, that works but how do I get to boot into bash as user wojowhiskey not root? What file must I amend? Dec 26, 2016 at 0:54
  • I did manage to make it work by placing "su wojowhiskey" in the $HOME/.bashrc file. Now however I can not access the root file. Dec 26, 2016 at 2:07
  • Yes because the root files are owned by the root not wojowhiskey. Whenever you have to access those files, either you prefix your command with sudo or type sudo su - to switch to root user Dec 26, 2016 at 17:29
  • wojowhiskey@STANSTOY:~$ sudo su [sudo] password for wojowhiskey: wojowhiskey is not in the sudoers file. This incident will be reported. wojowhiskey@STANSTOY:~$ Dec 27, 2016 at 4:36
  • I get this when I first login to bash: Dec 27, 2016 at 4:38
1

Few days ago I had to set default user to root in order to change user password. To set default user do:

<distro> config --default-user <user>

In my case

To set root as default:

ubuntu1804 config --default-user root

To set anand as default:

ubuntu1804 config --default-user anand
0

From the Windows command prompt: (don't type it in bash.exe)

lxrun /setdefaultuser wojowhiskey

lxrun is pretty powerful, check it out:

C:\> lxrun /?
Performs administrative operations on the LX subsystem

Usage:
    /install - Installs the subsystem
        Optional arguments:
            /y - Do not prompt user to accept
    /uninstall - Uninstalls the subsystem
        Optional arguments:
            /full - Perform a full uninstall
            /y - Do not prompt user to accept
    /setdefaultuser - Configures the subsystem user that bash will be launched as. If the user does not exist it will be created.
        Optional arguments:
            username - Supply the username
            /y - If username is supplied, do not prompt to create a password
    /update - Updates the subsystem's package index
1
  • For new Windows 10 release Fall Creators Update and later, lxrun is deprecated. Use distro_name.exe instead, i.e., ubuntu.exe aka.ms/wslusers Jan 16, 2018 at 18:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.