


Additionally, locking an entire folder applies the setting to everything within it, protecting all contained items from accidental alteration. Here’s how the feature works: locking a document or other editable item means you can open the file and read the content, but macOS will prevent you from making any changes. Run the ln command in the following form. Navigate to Finder > Applications > Utilities > Terminal to launch the Terminal shortcut. Press Command+Space, type Terminal, and then press Enter to open Terminal from Spotlight search.

Related: Tips for Managing Files or Folders in Finder on Your Mac To create a symbolic link on a Mac, you’ll need to use the Terminal app. Even if you’re a solo user, accidents do happen, and any extra layer of protection against data loss is worth the effort. If you share your user account with other people, locking your most valuable items may be beneficial. The usefulness of the feature will depend on how you and others use your device. The main reason for locking files and folders in macOS is to avoid accidentally altering or deleting important items. Reasons for Locking Files and Folders in macOS Let’s take a look at file locking in more detail and discuss how each method works. In macOS, you can use Finder and Terminal to lock files and folders to protect the most important ones. Remember you're only able to do this because you used the sudo command to gain admin privilege, otherwise you would not have permission to overwrite what the system considers to be a very important file.Does your Mac hold important data? Do others use your device? Are you prone to accidentally altering or deleting critical files? In any case, locking down your most valuable files can help prevent data loss and future frustration. You will be asked for a location and file name, but seeing as you're overwriting a file all you need to do is press Enter. Once you've added a commented-out description, an IP and a domain you should save the file using the keyboard shortcut Control+O which calls the WriteOut function. Rules should be added in the following format:, for example: adding "127.0.0.1 " would redirect all requests (but not requests) to your local machine, essentially blocking your machine from accessing Google's servers. Similarly, you can use comments to quickly enable or disable changes without removing the rule entirely. If a line starts with a # it's ignored, so you can use these lines to help keep the file tidy with descriptions of what each addition does. Pay attention to the comments, which are signified by "#" symbols. You'll have to use the arrow keys to move the cursor around as your mouse pointer will not work here.

Of course, this only provides a loose safety net as advertisers, spammers, malware distributors and anyone else you might want to keep out are wise. This also helps prevent the rest of the web accessing that server easily.Īnother example would be to block access to a domain, so when a website redirects you to an adserver or partner site, you could block that site by adding a line in your hosts file which redirects the IP to your local machine (127.0.0.1). By pointing a domain or sub-domain like "" to the IP at which the development site is located it is easier to access the site. There are a range of uses, though the vast majority involve security, blocking hostnames and preventing connections being made.Īs an example, web developers often have to use this file to access developer servers which aren't tied to a domain. process Terminal tell application Terminal activate if terminalIsRunning is true. If an existing domain is added to this file along with an IP, it will call on that IP rather than where the domain name normally points. The hosts file is used to route hostnames including website addresses to IP addresses.
