Making a directory on unix readable,writeable,executable by me and no one else?
Solution 1
You could always be explicit
$ chmod 700 mydir
where "700" is interpreted as an octal number specifying the bits to set from rwxrwxrwx
(for user|group|eveyone) so that 700 = rwx------
.
Solution 2
This command
chmod g-rx mydir/
removes read and execute permissions from group. It will leave intact any permissions for other (everyone), and write permissions for group.
It is different to:
chmod a-rx mydir/
chmod u+rx mydir/
Because a-rx
impacts all three rights. It still leaves write permissions in place however for group or other.
The best way to do it is to set all permissions explicitly:
chmod 0700 mydir/
The 7 is binary for 111, where each bit represents read, write and execute respectively, at that position, refers to user (the file owner). The four positions in the 0700
refer to "special"
permissions, user
permissions, group
permissions and other
permissions respectively.
Use this to help translate between the number associated with rights, and the read, write, execute flags.
http://permissions-calculator.org/
user46976
Updated on September 18, 2022Comments
-
user46976 over 1 year
What is the proper way to make a directory that I created and all of its contents readable/writeable/executable only by me, and no one else?
Is this sufficient:
chmod g-rx mydir/
this should make it unreadable/unexecutable to everyone except me, right?
Also, how is the above different from?
chmod a-rx mydir/ chmod u+rx mydir/
thanks.
-
kbyrd over 12 yearsNo matter what, the root account could always change your permissions and view the directory and it's contents.
-
glenn jackman over 12 yearsyou probably want
chmod go-rwx
-- group and other have no permissions.
-
-
dmckee --- ex-moderator kitten over 12 years@ppuschmann: Yeah, that was pretty unclear. Is the edit better?
-
ppuschmann over 12 yearsyes, great. Thx.