You can use chown
to change ownership of files and folders. The syntax is:
sudo chown <user>:<group> /path/to/files
So for example, if you wanted to make the user "john", the owner of ~/myfile.txt
you would run:
sudo chown john:john ~/myfile.txt
The same goes for folders, however if you need all folders and subfolders changed at once, you would use the -R
flag, like so:
sudo chown -R john:john /path/to/my/directory
(You can use pwd
to find out the current directory)
This will work for any file and folder on the system, however you should not do this on system files or it can damage the entire OS (many programs depend on ownership and permissions being set correctly). However if there are files and folders that are incorrectly owned by root
, you can use the above commands to change ownership of them.