Ubuntu – Stuck in terminal as root user

command linerootusers

I've recently downloaded Ubuntu onto my laptop. Whenever I open the 'Bash on Ubuntu on Windows' app, it immediately opens the terminal in the root user as seen in this picture.

I want to access my computers normal directories, such as Documents, Desktop etc., however when I write ls it is empty. I've tried a lot of things, including cd /home/username/ (which just says that there is no file or directory), writing exit (which simply crosses of the terminal and doesn't log me out). It may also be worth noting that I was never asked to create a username or password when installing Ubuntu.

Best Answer

Users, user management, and privilges are discussed at https://msdn.microsoft.com/en-us/commandline/wsl/user_support

Although the user you are running as is "root" I do not believe the user has administrative rights on windows, not sure about the bash environment, but I personally would change names. I am surprised ubuntu did not set up a non-root user as part of the install.

From that site, run the following commands on the correct OS:

"username" is the user you want to run ubuntu as, change as necessary.

From Ubuntu (root shell)

passwd username

From WINDOWS (cmd) run:

C:\> ubuntu config --default-user username

I am not sure about access to windows files from ubuntu, it may or may not work once you change users, but, as explained in the link, access is kept separate and windows permissions are not the same as ubuntu permissions.

If it works you should see your windows files in Ubuntu at /mnt/c/ , so Documents and such should be at /mnt/c/Users/your_windows_user/Documents/ and such.

If it is not working, ask a separate question and provide details with any error messages you get.