Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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

Just curious, are these two completely equivalent?

chmod +x file
chmod 0755 file

Thanks :-)

share|improve this question

migrated from Mar 25 '12 at 14:20

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

No, because +x just adds x to the current mask for everybody, not influencing rw, while 0755 changes the whole mask. – Ondrej Kupka Mar 25 '12 at 13:07
-1 You would have found this out if you read the man page for chmod and possibly the wpedia page for Filesystem permissions. – Eroen Apr 19 '12 at 15:55
up vote 3 down vote accepted

chmod 0755 file is equivalent to u=rwx (4+2+1),go=rx (4+1 & 4+1). The 0 specifies default special modes (see comment below). See wikipedia for more info (including tables describing u,g,o,a and r,w,x,s,t,).

So in other words: No, they're not equivalent since 0755 contains more flags.

See also: chmod man page

share|improve this answer
That's not accurate. The 0 specifies set UID (4), get GID (2) and sticky bit (1) in the first of the 4 numbers. If omitted, it assumes a padded 0 on the front. – iandouglas Mar 25 '12 at 13:12
@iandouglas But "if omitted, it assumes a padded 0 on the front", should then mean that 0 is the default? So in other words, you're just saying that it should say "no special special modes" ? – keyser5053 Mar 25 '12 at 13:26
To my knowledge, yes, 0 is an implied default, so "755" should be the same as "0755" – iandouglas Mar 25 '12 at 13:54
@iandouglas post edited – keyser5053 Mar 25 '12 at 13:57

Chmod number sets the permissions to exactly that number. Chmod relative only changes the requested bits. A file whose permissions were 000 before chmod +x will now be 111.

share|improve this answer

No, because chmod 755 also sets various read and write flags.

share|improve this answer

Assuming your file was already chmod 644, then, yes, they are effectively equal. It's better to explicitly list the bits you want to set though, using something like a+x

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .