By accident I ran chmod -u filename
and it removed all of the permissions I had on filename
.
The man page does not reference a -u
option. Experimenting I was able to conclude that it removes not all permissions, but just read and execute access, leaving write access intact.
So what does this do exactly?
My conclusion above is wrong, I now think that what it does is remove the permissions that the owner has, from all categories.
I think the behavior is analogous to a=u
, only it is -
instead of =
and a
can be dropped just as it can with, for instance, a+x
.
Best Answer
This is not an option, but a standard (but uncommon) way of specifying the permissions. It means to remove (
-
) the permissions associated with the file owner (u
), for all users (no precedingu
,g
, oro
). This is documented in the man page.GNU chmod's man page documents this as:
and later
So
-u
means to remove (-
) whatever permissions are currently enabled for the owner (u
) for everybody (equivalently toa-u
, except honouring the current umask). While that's not often going to be very useful, the analogouschmod +u
will sometimes be, to copy the permissions from the owner to others when operating recursively, for example.It's also documented in POSIX, but more obscurely defined: the permission specification is broadly
who[+-=]perms
(or a number), and the effect of those are further specified:and then