macOS Troubleshooting: Why chmod 777 Is Not a Permissions Fix

Updated

mac troubleshooting guide

Never use chmod 777 to fix “Permission denied”: it gives every account on the machine write access and leaves ownership where it was. Take ownership instead with sudo chown "$(whoami)" /path/to/file, then set 644 for data or 755 for scripts and directories. If the error survives a mode change, check for an ACL with ls -le.

chmod 777 is not a permissions fix

777 does not grant you access; it removes the restriction for everyone, and ownership does not move:

$ chmod 644 f.txt; stat -f "%Sp %Su %Sg" f.txt
-rw-r--r-- [user] staff
$ chmod 777 f.txt; stat -f "%Sp %Su %Sg" f.txt
-rwxrwxrwx [user] staff

Owner and group unchanged. What moved is the third triad, “other”, which now has write. Any other account on the Mac can now silently rewrite that file. On a shell script, 777 leaves it world-writable and executable, which is how a local account escalates the next time root runs it.

People reach for 777 because chmod on a file you do not own fails; chmod(2) says “[EPERM] The effective user ID does not match the owner of the file and the effective user ID is not the super-user.” So they add sudo, it succeeds, and a root-owned file is world-writable. Fix ownership instead:

sudo chown "$(whoami)" /path/to/file    # then a normal mode
chmod 644 /path/to/file                 # data
chmod 755 /path/to/script.sh            # scripts, and directories

Scope that chown to something you created: a file, a project directory, anything under your own home folder. Never point it at /System, /usr or /Library. Those belong to root or to a system daemon deliberately, and System Integrity Protection refuses writes there whoever owns them: ls -lO /bin/ls prints a restricted flag and csrutil status reports SIP enabled. Taking ownership does not make such a file writable; it just leaves you owning system files. A system path that denies you is a different failure with a different fix.

macOS ships nothing world-writable in its command directories, and its shared directories are not 777:

$ find /bin /sbin /usr/bin /usr/sbin -type f | wc -l
    1175
$ find /bin /sbin /usr/bin /usr/sbin -perm -0002 | wc -l
       0
$ mkdir d && chmod 777 d && stat -f "%Sp %N" d /private/tmp /private/var/tmp
drwxrwxrwx d
drwxrwxrwt /private/tmp
drwxrwxrwt /private/var/tmp

That final t is the sticky bit: only a file’s owner may delete it. A hand-made 777 directory gets x instead, so anyone can delete anyone’s files in it.

The ACL case people mistake for “777 didn’t work”

macOS attaches ACLs that ls -l hides and numeric chmod does not touch; Apple puts one on your home folders:

$ ls -lde ~/Desktop
drwx------@  6 [user]  staff   192 May 25 10:00 /Users/[user]/Desktop
 0: group:everyone deny delete

Give a scratch file a deny entry and 777 achieves nothing, because a deny ACE is evaluated first:

$ chmod +a "everyone deny write,append,writeattr,writeextattr,delete" acl.txt
$ chmod 777 acl.txt && ls -le acl.txt
-rwxrwxrwx@ 1 [user]  staff  5 Aug 11 12:38 acl.txt
 0: group:everyone deny write,delete,append,writeattr,writeextattr
$ echo more >> acl.txt
/bin/bash: line 49: acl.txt: Permission denied
$ chmod -N acl.txt && echo more >> acl.txt && echo appended
appended

So when an error survives a mode change, run ls -le, not a bigger number. chmod -N clears the ACL; chmod -a removes one entry.

Run chmod -N on the one file that is actually failing, and never on a home folder. That group:everyone deny delete entry above is Apple’s, not a leftover: the same ACE is on ~/Desktop, ~/Documents, ~/Downloads and ~/Library, and it exists to stop something deleting the folder itself. chmod -N ~/Desktop strips a protection you did not diagnose and cannot easily put back. If what is blocking you is one entry rather than the whole list, remove that entry with chmod -a and leave the rest alone.

Four common Mac fixes that fail on Apple silicon

Resetting NVRAM, resetting the SMC, holding Command-R for Recovery and bouncing ifconfig en0 to “renew your DHCP lease” are all wrong on Apple silicon, and each has its own page here:

  • NVRAM. Option-Command-P-R is an Intel-only startup key with no Apple silicon equivalent, and sudo nvram -c is not the Terminal substitute: Reset NVRAM on a MacBook.
  • SMC. On Apple silicon, restarting is the entire procedure, and the SMC itself is still present, which is a different claim from “there is no SMC reset”: Reset the SMC on a MacBook.
  • Recovery. You enter it by pressing and holding the power button, not Command-R, and a factory reset does not need Recovery at all: Factory reset a MacBook. For the password case specifically, Reset a macOS password from Terminal.
  • DHCP. ifconfig en0 down then up is a link bounce that disconnects the interface carrying your default route; it renews nothing: MacBook Wi-Fi has no IP address.

Homebrew’s installer and hiding desktop icons

Homebrew. Homebrew’s one-line installer is the genuine official one: brew.sh publishes the same one-liner. It is not silent. It asks for your admin password, and on Apple silicon it writes to /opt/homebrew, not /usr/local:

$ grep -A3 'UNAME_MACHINE.*arm64' install.sh
  if [[ "${UNAME_MACHINE}" == "arm64" ]]
  then
    # On ARM macOS, this script installs to /opt/homebrew only
    HOMEBREW_PREFIX="/opt/homebrew"
$ grep -n 'sudo access' install.sh
263:    abort "Need sudo access on macOS (e.g. the user ${USER} needs to be an Administrator)!"
$ brew --prefix
/opt/homebrew

Fetch it with -o install.sh and read it before piping it into a shell; the output above comes from a copy fetched that way.

Hiding desktop icons. defaults write com.apple.finder CreateDesktop false; killall Finder is a display toggle, not a cleanup: the files stay in ~/Desktop. Not executed here; defaults read com.apple.finder CreateDesktop reports the pair “does not exist”, the unset default, icons shown. Writing true restores it.

One edit to the output above: the account name in every command result on this page has been replaced with [user]. Nothing else is altered: the commands, their output, the permissions, the timings and the errors are exactly as they ran.

Photo of author
Sudhir P. founded HeatWare.com in 1999 and has built and operated it full-stack ever since; it is now used by more than 88,000 people. He writes here about the PostgreSQL, MySQL, Linux and DevOps work that keeps it running. Articles are rewritten only after the commands in them have actually been run, and the verification scripts are published alongside them so anyone can check the claims. Reach him at blog@heatware.net.