Quantcast
Channel: Active questions tagged windows-subsystem-for-linux - Ask Ubuntu
Viewing all articles
Browse latest Browse all 2930

Ownership issues with WSL2 and Ubuntu 22.04

$
0
0

I'm setting up a fresh installation of Ubuntu 22.04 on Windows 11, and I've had several issues related to the default ownership and permissions. I'll go through the issues I've had and my attempts to solve them

  1. mkdir: cannot create directory ‘rails’: Permission denied

I was following a Ruby on Rails tutorial on setting up WSL2 with Rails 7

At 6:55, the youtuber says to change into the root directory to improve the speed of the computer so that your programs aren't being pulled from your windows file directory. When I attempt to mkdir, I get that error. I can only interact with the root directory when I use sudo. Small random note, by default, my terminal uses $ which means I'm not the superuser as opposed to the video showing a hashtag # instead. I could use sudo before each mkdir, but this is inefficient and I'm afraid it might be dangerous because I'm not sure why I'd need to sudo. This might be the key to resolving the next few issues.

  1. sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set

According to another post, I decide to start working in the ~ directory (I don't seem to understand the difference or significance, but I'm no longer seeing permission denied.) I am able to install the right versions of ruby on rails for the project I'm going to work on and I start using bundler to install the necessary gems. One of the gems depend on libcurl4-openssl-dev, so I download it based on what this post recommended. I tried using sudo and that's how I got this error.

  1. chown: changing ownership of '/usr/bin/sudo': Operation not permitted

This post recommends logging in as root and executing some commands, but I'm unsure how to do that using WSL2. chown root:root /usr/bin/sudo && chmod 4755 /usr/bin/sudo

All these issues seem to boil down to permissions.

I've hit this problem at a few different angles. I can't seem to find the main cause of the issue - I've reinstalled Ubuntu and WSL a couple times to no avail. It looks like I need to set some sort of permissions in WSL2 or in Ubuntu, but the different ways to grant me those permissions are locked.


Viewing all articles
Browse latest Browse all 2930

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>