Operation not permitted and permission denied - macos

My mac version is 10.12.2.
I'm trying to install R studio and a number of other softwares, but it doesn't work. I suspect it's because of permission issues - my mac doesn't allow them to create directories during installing.
~$ pwd
/Users/biona001
~$ mkdir fdsa
mkdir: fdsa: Operation not permitted
but if I'm in a higher director, it says something different
~$ cd ../
Users$ pwd
/Users
Users$ mkdir fdsa
mkdir: fdsa: Permission denied
and if I move into a lower directory, it works
Users$ cd biona001/Documents/
Documents$ mkdir fdsa
Documents$
I googled almost everything without finding anything that worked, including the one where I boot my mac into this weird mode and type some command. I should be the administrator of this mac.

R Studio is installed by dragging the application to your applications folder. It requires R to be installed. R can be installed from a package, so you don't need the command line.
The 'administrator' on the mac, does not have permission to write files or create folders anywhere. It's not a good idea in any case.
If it's absolutely necessary, you must enable 'root' and login as root. But this is not necessary to use R Studio and R.
Enabling root access without knowing exactly what you are doing is a recipe for disaster.

I had the same "operation not permitted" issue on MacOS Sierra.
Looking at the user's home folder in Finder as John Elemans recommended, showed that the home folder was locked. Unchecked the locked checkbox in finder and was able to create a subfolder in the user's home folder via terminal.

Related

cd: permission denied: Downloads on Mac OS terminal

I was trying to connect to an EC2 instance on AWS using chmod and ssh and some how lost permission to cd into my Downloads
Apparently must have messed something up while attempting to do it since it is my first time.
I forgot to cd into the location of my Key and instead and tried a bunch of things that did not work including
chmod 400 /Users/chistopherholder/Downloads
and
chmod 400 /Users/chistopherholder/Downloads/Key-name.pem
when I realized I needed to cd into the location (by looking air a different tutorial on YouTube) I tried and con the permission denied.
How do I revert what I have done? So that I can cd into Downloads like before.
There is a way to reset the permissions on a Mac terminal with by running
diskutil resetUserPermissions / `id -u`
This worked for me and allowed me to cd back into the Download file
What worked for me is resetting the permissions for "Files and Folders" of the Terminal app:
System Preferences -> Security & Privacy -> Privacy tab -> Files and Folders -> find the Terminal.app and check all the boxes next to:
Downloads folder
Documents folder
Desktop folder

Install package in RStudio got permission denied

I was trying to install rattle package in RStudio in Mac but had this problem.
The downloaded source packages are in
‘/private/var/folders/jg/725mdnns39z944j_s1q2hwg40000gn/T/Rtmpe2a0uF/downloaded_packages’
Updating HTML index of packages in '.Library'
Warning messages:
1: In file.create(f.tg) :
cannot create file '/usr/local/Cellar/r/3.6.3_1/lib/R/doc/html/packages.html', reason 'Permission denied'
2: In make.packages.html(.Library) : cannot update HTML package index
I tried the following methods:
One
I used the following lines to change folder permission
ls -ld /usr/local/Cellar
sudo chmod a+w /usr/local/Cellar
The folder permission is changed as follows:
drwxrwxrwx 118 dph admin 3776 Apr 23 00:40 /usr/local/Cellar
But the problem still not solved.
Two
I found .libPaths() to check lib directory and change that folder's permission, too. It doesn't work.
Three
I used .libPaths("/home/rlib") to change installation place. Doesn't work.
Four
I moved to the terminal rather than the RStudio console to install the package. As I suspect RStudio may have no right to access folders. When installing, the terminal asked me allowing the terminal to access folders? But even choosing yes doesn't work.
My suspicion is correct. One comment in the RStudio forum said we need to open the application on administration mode. And I found in Mac, you can do this:
cd /Applications/iTunes.app/Contents/MacOS/
sudo ./MacOS
And it is working!!

Lost permission for sudo in OSX El Capitan

I'm new to using OSX (using El Capitan 10.11.3) and while trying to change permissions on a file using sudo, I accidentally corrupted it. Now whenever, I try to use sudo to install anything globally, I'm getting the following error message.
sudo: unable to stat /etc/sudoers: Permission denied
sudo: no valid sudoers sources found, quitting
Is there any way to solve it?
I'm also unable to even view the /etc folder
bash: cd: /etc: Permission denied
When I checked permissions on /etc folder, they are as follows
lrwxr-xr-x# 1 root wheel etc -> private/etc
I had the same issue and in my case the permissions of the root folder got corrupted. What people overlook is that / is in fact also a real, normal directory and just like every directory it has ownership and permissions. Ownership should be root:wheel and permission should be 755 (that's rwxr-xr-x).
The easiest way to restore both was starting Script Editor and then typing and running that script:
do shell script "/usr/sbin/chown root:wheel /" with administrator privileges
do shell script "/bin/chmod 755 /" with administrator privileges
You are prompted for amdin password and then chown and chmod come to the rescue. After that sudo was working again.
Disable System Integrity Protection (rootless)
Reboot the Mac and hold down Command + R keys simultaneously after you hear the startup chime, this will boot OS X into Recovery Mode
When the “OS X Utilities” screen appears, pull down the ‘Utilities’ menu at the top of the screen instead, and choose “Terminal”
Type the following command into the terminal then hit return:
csrutil disable; reboot
You’ll see a message saying that System Integrity Protection has been disabled and the Mac needs to restart for changes to take effect, and the Mac will then reboot itself automatically, just let it boot up as normal

File Permissions Issue On Mac

I'm not very familiar with Terminal / Command line on Mac, outside of basic commands (cd, ls, pwd ect.) And I was trying to install "compass" for Sass.
http://compass-style.org/install/
When I tried the first line that they give
$ gem update --system
I got an error in terminal saying that the file permissions were wrong for /usr/bin folder. So I updated that folder to 777, but then I got a warning message stating that
Insecure world writable dir /usr/bin in PATH
So I thought it didn't like that I set the permissions so high, so I updated the permissions for that folder to 744, thinking I would still be able to do what I needed..... Now I've been locked out of that folder, and I can't do much in terminal, because it seems like most commands originate from that folder? I can't change the permissions back I can't use sudo, or many other commands. It seems like a lot of the commands are located inside of the /usr/bin folder.
How can fix this? Is there a way to change the permissions back in this folder? Can I update the permissions of the /usr folder and have it modify all sub-folders?
Disk Utility's repair permissions feature should be able to fix this. Run Disk Utility, select your startup volume in the disk & volume sidebar on the left, select the "First Aid" tab on the right, then click "Repair Disk Permissions". It's possible the system is broken to the point where that can't run, but if it can run it should fix the permissions on /usr/bin.
I'm not familiar with the gem system, but in general your customizations/updates/etc shouldn't be modifying /usr/bin or anything in it. Your stuff should go someplace like /usr/local/bin, and the permissions for that can be something like 775 (never 777), and it can be assigned to the admin group so you can write to it.
try:
sudo chmod go-w /usr/local/bin
There is a post for more reference:
warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777

Changing Ownership of a directory in OS X

I've installed homebrew, and am trying to change the write permissisons for the /usr/local/include directory.
When I run 'brew doctor', I get this error message:
Error: The /usr/local directory is not writable. Even if this
directory was writable when you installed Homebrew, other software may
change permissions on this directory. Some versions of the "InstantOn"
component of Airfoil are known to do this.
You should probably change the ownership and permissions of /usr/local
back to your user account.
I tried doing that with chown, but I'm pretty new at this and don't think I was running it correctly. I ran:
chown myusername /usr/local/include
I didn't get any error message, but when I run brew doctor it says I still lack permission to write to /usr/local/include.
Any help would be greatly appreciated!
Edit:
I'm getting an "operation not permitted" error.
cd /usr
chown myusername local
chown: local: Operation not permitted
Simple solution that worked for me:
click on your background to go to finder
click on go and go to folder /usr
right click on local and do get info
unlock the lock at the bottom
click + sign and add your user to the list and give read/write privileges
click on the gear sign at the bottom and choose apply to enclosed items to recurse under that directory and assign privileges too all directories beneath it.
type brew doctor from command prompt to test. My result:
Your system is ready to brew.
On my system, /usr/local is owned by root:admin and is rwxrwxr-x. My user is a member of the admin group, thus has write permissions. I haven't messed with ownership and permissions there, and my Homebrew installation is not complaining, so I assume my setup fits its requirements.
Check the ownership of your /usr/local; if it is owned by group admin, check if your non-adminsitrator account is a member of that group.
You should use: sudo chown username folder
Be careful with the change of ownership
Do not try to change ownership for /usr/ or recursively for /usr/local/
if you are not getting the same error posted in the original question.
You could screw up your system or weakness its security.
Some users can receive with homebrew permission errors that could be solved without changing the ownership of the whole /usr/ or /usr/local/ directories.
According to my experience, in most cases, it is just enough to restore the ownership for /usr/local/Cellar:
sudo chown -R "$USER" /usr/local/Cellar/
Alternatively, if you have a not standard installation
sudo chown -R "$USER" "$(brew --prefix)/Cellar"
You can try use command ls -l. With this command you will see list of files in current directory with some useful information, like who is owner of this file. So you will see if chown worked out. I believe that chown is a right command for changing ownership.
Exactly this problem has just started occuring on my MacBook.
The owner of /usr/local is:
drwxr-xr-x 24 root wheel 768 Apr 9 17:25 local
I am unable to change the permissions and add myself via Finder - I get a "you don't have the necessary permission" error.
Is this maybe due to security changes in mac os? (I have 10.13.6)

Resources