whats the difference between chmod 777 and chmod 7777

In 7777, the first three bits are the setuid, setgid, and sticky flags. These should only be set under very special circumstances. You're correct that 777 is the more appropriate setting (if you want to make the file both world-writable and world-executable).

And unless the file is an executable program or script, or a directory, you usually shouldn't set the x bits. There's not much harm in doing so, though.


There is no reason for a sensible professor to insist setting the setuid/gid and sticky bits so perhaps are you confusing 7777 and 0777.

The permissions being stated as an octal number, the proper convention to represent them is to prepend a 0. This is just like when 0x is used to distinguish an hexadecimal number.

Note that chmod doesn't expect the permissions to be expressed in decimal or hexadecimal so this octal prefix is optional.

Tags:

Unix

Chmod