102
53
I copied a lot of read-only files from a Windows system to my Mac. When viewing the Info for each file using "Get Info", I can see they are Locked. I'm writing a bash script to copy over some files and I'm getting an error that says "Operation not permitted" So, first I need to unlock the files. Since I'll be pulling files from the Windows system often, I want my script to unlock these files.
What is the terminal command to unlock "Locked" files on OSX?
3
There's another relevant flag
– Andy Madge – 2015-01-12T20:22:56.377schg
which is the system immutable flag (see https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/chflags.1.html) The command to clear it is similar:sudo chflags noschg PATH/TO/LOCKED/FILE
1Use
/bin/ls -lO /path/to/file
to view the macOSflags
on files. Notice the full path to the macOS 'ls
' command. This is needed if you have GNU Coreutils installed. – Tony Barganski – 2018-11-07T05:57:13.8371
Looks like I found the solution just as you were responding. I also learned that the -R is for recursive. So, to unlock all files in the current directory use<br/> chflags nochg *<br/> and to change just one file<br/> chflags nouchg onefile.txt See: http://www.mehtanirav.com/2009/04/16/recursively-unlock-files-on-mac-os-x
– Michael Prescott – 2009-09-14T02:37:54.607