wp_20170120_09_43_22_pro

In the first blog (https://www.suse.com/communities/blog/make-windows-green-part-1/) of this series I explained how to get openSUSE Leap 42.2 running within the Windows Subsystem for Linux (WSL) of Windows 10. Now it is time to make it run properly because it’s not in a state I’d like to see it out there in the wild. In this blog I’d like to focus on correcting the user default login. I said that I would include graphical tools in my next blog, but that would make this blog much too long so I will cover that topic in Part 3.

Please give me any feedback you have using the comment function at the end of this blog.

When we replaced the originally delivered Linux within WSL with openSUSE Leap 42.2 we had to set root as the default user – simply because the openSUSE Leap 42.2 archive we downloaded and unpacked didn’t know about our user. Running Linux with root as default user isn’t a good idea so let’s change the default user back to <linux_user> – or the user name that you’ve chosen. But before doing so, we need to install a tool called “sudo”, which is not included in the openSUSE container that we extracted by default. For those not familiar with sudo, it’s a program that allows a user to temporarily gain root (aka Administrator) permissions to perform administrative tasks. For security reasons it’s the default on Linux to use a regular user for daily tasks and only use root when tinkering with the system.

  • Open the openSUSE bash (click the Windows button, type “bash” and then hit Enter), enter the following command:
     $ zypper in sudo

    Wait a little while until zypper has fetched all necessary repository information, and confirm the next question by pressing [y] to install sudo. Don’t close the openSUSE bash yet because there are still a couple of commands we have to execute.

  • Now we have to create the regular Linux user within openSUSE bash. Before doing so, we need to understand that the user’s home directory is not stored in the rootfs folder, which we replaced. It’s a separate folder under %localappdata\lxss\home and is already available within openSUSE. While still in the openSUSE bash, you can navigate to the folder /home and check for yourself.
    $ cd /home
    $ ls -la
    total 8
    drwxr-xr-x 2 root root 0 Jan  1  1970 .
    drwxr-xr-x 2 root root 0 Jan  1  1970 ..
    drwxr-xr-x 2 1000 1000 0 Jan 20 08:52 <linux_user>

    The folder is currently not owned by anyone known to the openSUSE system, which is indicated by the fact that there are only numbers set for user and group (highlighted in red) and not names. Let’s change that by adding the <linux_user> to openSUSE.

     $ useradd <linux_user>
  • Now, the former Linux and openSUSE Leap use a different default group ID for users. Where the former Linux is using ID=1000, openSUSE is using ID=100. Here’s an example how it looks on both systems:
    # former Linux
    $ grep users /etc/group
    users:x:1000:
    # openSUSE Leap 42.2
    $ grep users /etc/group
    Users:x:100
  • Although having a proper user (owner) set for the home directory, the group is still off. With the “id” command you can check the user and the group settings for the user.
    $ id <linux_user>

    The group ID is different than the one that’s already set for the home directory

    $ ls –la /home
    total 8
    drwxr-xr-x 2 root         root 0 Jan  1  1970 .
    drwxr-xr-x 2 root         root 0 Jan  1  1970 ..
    drwxr-xr-x 2 <linux user> 1000 0 Jan 20 08:52 <linux_user>

    So let’s get this fixed with this command

    $ chgrp 100 /home/<linux_user> -R

 

  • Before changing the default user back, we need to give root a password so that we can use it properly (more experienced Linux users might want to work with /etc/sudoers instead).
     passwd root

    Enter a new password for the root and confirm by entering it again.

  • All what is left is to tell WSL to use <linux_user> as default user. Close the openSUSE bash and execute the below command in a cmd window:
    lxrun /setdefaultuser <linux_user>
  • The output of that command should look quite similar to this one:
    Found UNIX user: linux_user
    Default UNIX user set to: linux_user

And now we are done. Our user is properly setup and when starting openSUSE bash you aren’t root any longer, but <linux_user>. When installing software, you now need to put sudo in front of the regular zypper command, such as: “sudo zypper in <software>”. I believe we covered enough ground in this blog. Let look at installing (graphical) software in part 3 of this series.

Table of contents:

(Visited 1 times, 1 visits today)
Tags: , ,
Category: Enterprise Linux, openSUSE, SUSE Linux Enterprise Server, Technical Solutions
This entry was posted Friday, 20 January, 2017 at 12:34 pm
You can follow any responses to this entry via RSS.

Comments

  • fotang says:

    I have successfully completed all the steps.

    What surprise me is the kernel version:
    3.4.0+ #1 PREEMPT Thu Aug 1 17:06:05 CST 2013 x86_64 x86_64 x86_64 GNU/Linux.

    I expected the kernel version to be above 4.0.

    • w8wca says:

      I think – This is OpenSUSE Leap
      SUSE Linux Enterprise (SLE)

      Being an Enterprise Linux – is is not likely it will have the latest kernel

      Not 100% Sure as I have not been using SUSE for a while

      • Hannes Kühnemund says:

        SLES 12 SP2 ships a 4.4 kernel, so that’s pretty new.

        The kernel in WSL is not coming from the Linux, but from Windows 10. You can see that for example by running “cat /proc/version” in the SUSE bash , which reveals:
        Linux Version 3.,4.0-Microsoft (Microsoft@Microsoft.com).

  • Leave a Reply

    Your email address will not be published. Required fields are marked *