0

New to using CLI OS.

So I tried changing the owner of a particular folder from root to my user so I can avoid errors of access denied whenever I would publish my dotnet app.

Basically, this is the folder structure.

myAppFolder
 |
 ->myApp
   |
   ->All forders that make the app(folders, .cs, .sln and the likes)
   ->publish
   ->README.md

When I use ls -lart on myAppFolder it says that the owner is the root. Though when I go inside and ls -lart in it some files/folders' owner is my user already. I figured that if I use 'sudo chown -R user myAppFolder' it should also change the owner of all it's subfolders because of the recursive flag. (Correct me if I'm wrong.) But when I did execute the command the ownership did not change to my user. Is there something I'm missing here? Is my understanding of the used command wrong?

EDIT: The referenced Change folder permissions and ownership is where I actually got the command I used, I just edited it to 'sudo chown -R user myAppFolder' because I was already in the folder that contained myAppfolder which is /apps.

vhie
  • 101
  • 1
    sudo chown -R $USER:$USER myAppFolder - Formore see: https://askubuntu.com/questions/6723/change-folder-permissions-and-ownership – cmak.fr May 16 '19 at 04:59
  • Probably immutable bit is set for some of your files/directories, if this is the case, you'd have to remove the immutable bit first. Use lsattr to see file attributes and chattr -i. Take a look at the related man pages, man lsattr and man chattr – mook765 May 16 '19 at 08:19
  • @mook765 so the only way for me to change the owner of that particular file is to remove it and recreate it, is that correct? – vhie May 16 '19 at 09:58
  • @vhie No, if the immutable bit is set you need to remove the immutable bit first, then you can make changes to the file. But I don't know if that's the case here, you never provided any meaningful output from ls -l or lsattr. So how can we know? – mook765 May 16 '19 at 10:55
  • @mook765 so this is how it looks when I did the lsattr. http://prntscr.com/npm92m – vhie May 17 '19 at 02:23
  • @vhie On the few files/folders I can see in the picture no immutable bit is set. If the immutable bit is set on a file and you try to change the ownership of that file, you would get a permission denied-error. If you didn't get this error, then the culprit is somewhere else. – mook765 May 17 '19 at 05:52

1 Answers1

0

try this command in your terminal

sudo chown -R $USER:$USER /path/to/myAppFolder 

this is duplicate of this question Change folder permissions and ownership

cmak.fr
  • 8,696
GHOST
  • 347