Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

New mac user here. I tried creating a symlink (installing x11) in /opt:

ln -s /opt/X11 /usr/X11

But permission is denied. Obviously I can probably use sudo, but how do I know when doing so is required? Are there certain directories that require sudo? Does creating a symlink always require sudo? Does anyone know of a guide that might help me understand better?

Thank you in advance

share|improve this question

migrated from Dec 14 '12 at 22:21

This question came from our site for professional and enthusiast programmers.

This looks less like a programming problem and more like a question about what file permissions are. – melpomene Dec 14 '12 at 17:47
up vote 3 down vote accepted

sudo is required whenever you need to perform an operation that requires root privileges (such as touching stuff in /opt or /user). It temporarily elevates your permissions up to root.

See also:

share|improve this answer
thanks for the resources – tim Dec 14 '12 at 22:34

You need sudo whenever your user doesn't have the permissions required to perform the operation at hand. It is hard to give you any answer that is more specific because your user may or may not have certain privileges.

As a rule of thumb, privileges under Unix are often checked at the file level, meaning if your action involves reading or writing (or executing but that's a little tricky to define sometimes) to a file then you need those permissions. Directories are files for Macos in a way, where making a new file under it translates to writing to that directory, listing them requires read and entering the directory (cd for example) requires execute permissions.

You can see these permissions with ls -l and the different columns will tell you the user's, group's and everybodys permission to do read, write, execute operations (rwx). This is easy to understand for files for directories (or devices) it gets more interesting.

So in your example, you would need to run ls -l / and will find that your user doesn't own /usr, is not part of the right group and world(everybody) isn't allowed to write to /usr, which would be required because ln -s creates a special kind of file.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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