My goal is to prevent modify/read
permission of other users except the owner. On ubuntu forums as solutions both approach is given.
sudo useradd -d /home/newuser -m newuser chmod 700 /home/newuser # or # chmod go-rwx /home/newuser
[Q] Is there any difference between chmod go-rwx
and chmod 700
or both accomplish the same thing? If there is a difference which one is recommended?
go-rwx
removes read, write, execute permissions from the group and other users. It will not change permissions for the user that owns the file.
Therefore e.g. a file with 644 (rw-r--r--
) permissions will have 600 (rw------
) after the command.
chmod 700
on the other hand will always change the permissions to 700 (rwx------
), no matter the previous permissions.
So it depends on what you want to accomplish.
Notes:
-R
to change entire directories, this makes go-rwx
more useful, as the executable flag is usually only wanted on folders (so they can be entered) and program files that need to be executed.
Using 700
would add the executable flag to all files that don't have it yet, which is usually not what you'd want to do.chmod 700
would actually look like in the other notation is chmod u+rwx,go-rwx
or chmod u=rwx,go=
(grants all permissions to user that owns file, removes all permissions of group and other)ugo±rwx
syntax scheme.