I was following instructions to install WSJT-X (a radio software) and it had me move a file named sysctl.conf to my desktop and run the following terminal commands:

  sudo cp $HOME/Desktop/sysctl.conf /etc/
  sudo chmod 664 /etc/sysctl.conf
  sudo chown  root:wheel  /etc/sysctl.conf

After running these commands, my terminal display changed to look like this:

terminal pic

Whereas previously my name was before the dollar sign. Also, my date and time are now displayed incorrectly (set 8 hours in the future). Can someone please help me find out what I did wrong and how I can fix it?

If it helps, I think I accidentally inserted a space in the second command so it became

sudo chmod 664 /etc/ sysctl.conf

(Note: I'm a Linux guy and I have no experience with macOS. Take my answer with a grain of salt).

With sudo chmod 664 /etc/ you removed execute bit from the directory and in effect you cannot access (read, write) items living within. This includes (among others):

  • /etc/profile, where common PS1 is defined,
  • /etc/localtime, /etc/timezone or whatever macOS uses.

You need sudo chmod 755 /etc to revert this. Unfortunately no access to /etc/sudoers will probably prevent you from doing this directly. If you're extremely lucky, you still have a shell running as root (started for whatever reason before things went wrong) where you can invoke chmod 755 /etc without sudo. But probably you're not so lucky.

If the same problem occurred in my Kubuntu (no encryption or such), I would boot live USB Linux, mount the filesystem and fix the permissions. I don't know if you can easily fix macOS "from the outside" like this.

This (oldish) question deals with a similar problem where sudo doesn't work because of wrong permissions of /etc/sudoers. Possible solutions from answers:

This may be one of the rare cases where running "Repair Disk Permissions" from Disk Utility might actually be warranted.

If that doesn't work, follow […] suggestion of booting into single user mode to fix it

This one looks promising:

Another approach is using Automator.app.

Create a new workflow that contains something like the following:

do shell script "chmod 0440 /etc/sudoers" with administrator privileges

When you run it, it'll ask for your password and (presuming you're an administrator) it'll fix it.

This also works if you've messed up the permissions on a parent directory (eg making / something other than 755).

Keep in mind you need to chmod 755 /etc, so don't blindly paste the above code. Your case falls under "messed up permissions on a parent directory".

  • Hey! Just wanted to say thanks so so much for your answer, I was able to fix the issue by entering single user mode and using 'chmod 755 /etc'. – austin Feb 28 '19 at 6:30

You need to have the +x permission on a directory ("execute/traverse") in order to access any of the objects inside, regardless of having read permissions on those objects directly.

Your chmod 664 /etc command removed this by setting permissions to u=rw,g=rw,o=r (that's what the octal number decodes to), so now 1) the shell cannot access /etc/profile and /etc/bashrc, where the system-wide PS1 setting is kept; 2) the system cannot access /etc/localtime or its macOS equivalent, where the system-wide timezone parameters are kept.

Use chmod 775 or chmod a+x on the directory to restore it. (7 and 5 decode to =rwx and =rx.)

(Actually I'm not sure if /etc is supposed to be group-writable, even on macOS, so you might also want chmod 755 instead – or an additional chmod g-w.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.