Locking files and folders is a practical way to prevent unwanted editing of personal and sensitive information, and in some cases can prevent future data deletions and hassles. But how to lock the file on Mac OS?
The Finder and Terminal tools are used to lock files and folders on Mac OS and can prevent data from being erased. Doing so eliminates the possibility of unwanted file changes or deletions. Also, if you share an account with others, it may make sense to lock the folders.
Locking editable files and documents will still allow you to open and read its contents, but the operating system will prevent changes to the file. Locking a folder will also include all its contents, keeping files away from unwanted editing. If a user tries to delete a locked file, an error message is displayed from Mac OS to confirm the process.
Lock files and folders with Finder
The easiest and fastest way to lock files and folders on a Mac OS is to use the Finder tool. To get started, first, click on the item you want to control, then select the Get Info option and check the Locked option.

The selected item is now locked and there is no need to go through any additional steps. To return to the previous state, just check the Locked option in the Get Info window again. Locked files and folders will always have small icons next to them that make them easier to identify.
Lock file on Mac OS with terminal
Using a terminal is a more sophisticated way to lock things in Mac OS that is not very popular with ordinary users. First, you need to check the current status (locked or not) of the item with the terminal; As a result, open the terminal tool and then enter the following code in it. Note that instead of the phrase [File path], try to replace the desired file address. Then press the Return key.

Each indicator You can check the status of the lock on a particular item. If this expression is observed in the output of the said command, it can be concluded that the selected item was locked, otherwise, it can be ensured that it is not locked.
The following command can now be used to lock the unlocked items. Just replace [File path] with your desired file address and press Return.

There will be no difference in the end result between using a finder or terminal to lock files and folders, and in the end, the same function will be provided. The following command can be used to unlock an item through the terminal.

Note that using a file lock on a Mac OS cannot prevent unauthorized access to user information, and other encryption methods are available for this purpose. A locked file can be easily edited and deleted just by unlocking it. If you are looking for additional layers of security on your data, you can use the special encryption options and applications available for Mac OS.