terminal, root & operation not permitted

Joined
Jan 8, 2017
Messages
1
Reaction score
0
Points
1
I am running the latest Sierra OS 10.12.2. Recently compiled some code and while I could run it from any directory, I noticed that I cannot put the program into /usr/sbin. The cp command, while running it as root, returns "operation not permitted"

Here is the output:
sh-3.2# ls -ld /Users/bytelogic
drwxr-xr-x+ 22 bytelogic staff 748 Jan 7 16:36 /Users/bytelogic
sh-3.2# ls -ld /usr/sbin
drwxr-xr-x 246 root wheel 8364 Jan 3 14:36 /usr/sbin
sh-3.2# whoami
root
sh-3.2# touch test-cp
sh-3.2# ls -la test-cp
-rw-r--r-- 1 root staff 0 Jan 8 11:18 test-cp
sh-3.2# cp test-cp /usr/sbin
cp: /usr/sbin/test-cp: Operation not permitted
sh-3.2# sudo cp test-cp /usr/sbin
cp: /usr/sbin/test-cp: Operation not permitted
sh-3.2#

The only thing that I can see is that after su root somehow is in group "staff" and not in "wheel".

Can anyone shed light on this? I am little rusty with the command line.... Mac support tells me they are not allowed to provide support for the terminal...
 
Joined
Dec 11, 2010
Messages
1,808
Reaction score
40
Points
48
Location
Chicago
Your Mac's Specs
late 2012 mini w/SSD
I'm pretty sure those are reserved locations on mac os. Look at mac dev docs for user locations (not at my mac now sorry).
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
It looks like /usr/sbin is covered by SIP so that would explain why you can't copy it (only "system" can write to those locations). A better solution anyway would be to create a folder where you do have permissions and simply add it to the PATH. See here for more info.
 
Joined
Feb 14, 2004
Messages
4,781
Reaction score
166
Points
63
Location
Groves, Texas
Or just copy it to /usr/bin (not sbin).
That's where most executables go anyway.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top