Operation not permitted on cd/library/webserver/documents - permissions

I changed the chown from 755 to 775 for the Documents folder by typing the below command in the terminal. I am successful, and Documents permissions are now changed to 775:
David-MacBook-Air:/ Davidtyler$ cd /library/webserver/
David-MacBook-Air:webserver Davidtyler$ chown 775 Documents
However, when I reset permission of the Documents folder to 755, which is the default in the terminal, then the terminal gives me the message "Operation not permitted".
Here are the commands that I typed to reset the permissions of Documents folder from 775 to default 755:
David-MacBook-Air:/ Davidtyler$ cd /library/webserver/
David-MacBook-Air:webserver Davidtyler$ chown 775 Documents
chown: Documents: Operation not permitted

I guess you actually wanted to use chmod instead of chown.
chmod changes permission; while chown changes owner of a file/folder.
chown 755 don't make much sense unless there is really a user identified as 755.

Related

How to debug `podman unshare` commands / Podman permission issues?

I understand that podman unshare can be used to properly set the permissions on unprivileged containers.
So podman unshare chown 1234:1234 -R /home/user/volume can be used to set the volume to the properly mapped ids.
But I'm getting permission errors when I'm trying to do that:
podman unshare chown -R 1234:1234 -R /home/user/foo/bar; echo $?
chown: changing ownership of '/home/user/foo/bar': Operation not permitted
1
The first thing I thought about was directory permissions but it fails even if I'm giving the destination directory 0777.
I'm calling the command as user user and the parent directories have these permissions:
drwxr-xr-x root /home
drwxr-x--- user /home/user
drwxrwxrwx user /home/user/foo
drwxrwxrwx user /home/user/foo/bar
It isn't my intention to really use 0777 in production but something is off even with 0777 and it's not clear to me how to debug this.

Avoiding "/mnt/" while calling sudo chown -R in "Ubuntu on Windows"

I'm using Ubuntu on Windows.
I want to take ownership all of the files and folders in the current user profile.
To do that, I call
sudo chown -R USERNAME /
It works, but it also tries to chown all files in folders under "/mnt/".
This means it tries to work on all my Windows folders as well.
I don't want that.
How could I process only the files and folder in the user profile?
Thank you!

Apache File permissions issue in Ubuntu

I'm trying to use Apache to access a file on my Documents folder.
I tried the following:
sudo chown -R www-data:www-data /home/$USER/public_html
sudo adduser $USER www-data
sudo chmod -R 775 /home/$USER/public_html
As suggested by this post:
https://askubuntu.com/questions/26848/permissions-issue-how-can-apache-access-files-in-my-home-directory
Although this works, now I cannot edit or the files directly as the user (without using sudo), despite being a member of the www-data group. The only solution that seemed to work is using chmod -R 777 (which I rather not do).
Turns out all I had to do is restart the OS and it was sorted!

cd'ing permissions denied after enabling root user on mac os x 10.6.4

I enabled root in terminal by sudo passwd root and then attempted to cd a rails site folder located on my desktop. I got the error -bash: cd: /Users/fred/Desktop/sitefolder: Permission denied
How to get rid of this error/ enable all permissions for root? Thanks
Are you sure you called cd as root?
If yes, check if the owner of the folder is root. If not call
sudo chown /Users/fred/Desktop/sitefolder root
then check if the owner has reading permission. If not call
chmod 744 /Users/fred/Desktop/sitefolder
(this enables all permissions for owner and only reading permission for group and others). If you don't care much about that folder you may instead call directly
sudo chmod 777 /Users/fred/Desktop/sitefolder
giving all permissions to every user.

Files saved by my web application has different file permissions from parent

I have a folder in which new subfolders and files will be created automatically, by a script.
I want to maintain the user and group permissions recursively for all new folders and files placed in the parent directory. I know this involves setting a sticky bit, but I can't seem to find a command that shows exactly what I need.
This is what I have done so far:
sudo mkdir -p /path/to/parent
sudo chmod -R 660 myself:somegroup /path/to/parent
Thereafter, I want the 660 permissions to be set recursively to any folders and files placed in /path/to/parent
However, whenever Apache saves a folder/file it assigns it permissions of 700 with user and group set to the apache user. This is NOT what I want. I want all files/subfolders under the parent to have 660 permissions for myself:somegroup.
Actually the octal flag 660 is probably not even correct. The permissions I want are:
Directories placed under /path/to/parent are eXecutable by users with permissions
files are read/writeable by user myself and members of somegroup
Files and folders in /path/to/parent is NOT world readable
Can someone help please?
I am running on Ubuntu 10.0.4 LTS
sudo mkdir -p /path/to/parent
sudo chmod -R 660 myself:somegroup /path/to/parent
erm - not ideal.
If you want new files/dirs created to have the same group ownership you need to set the group sticky bit on directories
find /path/to/parent -type d -exec chmod g+s {};
And you need to make directories executable:
find /path/to/parent -type d -exec chmod ug+x {};
...
However, whenever Apache saves a folder/file it assigns it permissions of 700 with user and group set to the apache user
Then you also need to set the umask (0770) for the executing code (or directly change the permissions) and ensure the apache uid is a member of somegroup. IIRC to set the group sticky bit, umask should be 2770 - but do check the manual.
You can set apache to write new files with specific umask.
Todo so in RedHat/CentOS edit the file /etc/sysconfig/httpd, and change to:
umask 007
In debian/Ubuntu use the file /etc/apache2/envars with the same settings