MacOS - Manually open as read only
I hope this is not a repeat question—searching mostly turned up various versions of people having the opposite problem.
Is there a way to manually open a file as read-only?
The use case would be a file that I generally want write access to, but on a particular occasion want to be very confident I won't accidentally modify. For example, a shared document that I sometimes need to edit but currently only want to view. As a compulsive/instinctive saver, this would be a useful way to protect myself from myself.
I'm running Big Sur 11.2.1 on an early-2014 Macbook Air.
Obvious workarounds:
- Get info, change my permissions to read-only, open; once finished, close, change my permissions back: This is a hassle.
- Open, immediately Save As: Ideally I want to lock myself out before I even have a chance to break the file.
- Duplicate the file, open the 'scratch' version; generally, delete the scratch version once I'm done: Still sort of a hassle, but the best Plan B I can think of.
Final thoughts:
- I imagine this can be done from Terminal, and am happy to learn how, but any sort of GUI method would be best.
- I imagine there's a way to create a service for this? Not sure where to start.
Thanks!!
Solution 1:
You can do this in Finder with a simple keystroke and one click.
Before opening your file do this:
- Select the file in Finder
- Press
Command-I
(this is the same as Get Info in the File menu) - Tick the box next to Lock in the General section.
This sets the immutable bit - meaning you can't change the file in any way.
Leave the Get Info window open and, when you are finished, untick the Lock box to unlock the file.
You can create Services (or Quick Actions) to lock and unlock files, and associate a keystroke with them, but I feel is hardly with the effort. If you want to create them, run Automator and create a new Quick Action. This is what you need:
Save it with the name Lock.
Modify by changing the uchg
to nouchg
and save as Lock Off.
Now these appear as Services and in Finder's Quick Action submenu.
You can also associate them with keystrokes in System Preferences - Keyboard - Shortcuts - Services. I chose the keystroke combinations Control Command L
and Shift Control Command L
.