I read everything about chmod, but I don't get something. If I write chmod u=rwx file
this "affects" me for all rights on the file, and if I write chmod u+rwx file
this "adds" me all the rights on the file, but what is the difference between +
and =
?
2 Answers
Since you're specifying all the read, write and execute bits, there's no difference.
The difference comes if you only specify some of the bits:
$ umask 022
$ touch afile ; ls -l afile
-rw-r--r-- 1 jackman jackman 0 Aug 21 11:23 afile
$ chmod u+x afile; ls -l afile
-rwxr--r-- 1 jackman jackman 0 Aug 21 11:23 afile*
$ chmod u=x afile; ls -l afile
---xr--r-- 1 jackman jackman 0 Aug 21 11:23 afile*
from the man pages:
The operator + causes the selected file mode bits to be added to the existing file mode bits of each file; - causes them to be removed; and = causes them to be added and causes unmentioned bits to be removed except that a directory's unmentioned set user and group ID bits are not affected.