Take the 2-minute tour ×

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/


share|improve this question
No matter what, the root account could always change your permissions and view the directory and it's contents. –  kbyrd Dec 17 '11 at 22:58
you probably want chmod go-rwx -- group and other have no permissions. –  glenn jackman Dec 18 '11 at 2:02

2 Answers 2

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------.

share|improve this answer
700 = rwx------ –  ppuschmann Dec 17 '11 at 22:15
@ppuschmann: Yeah, that was pretty unclear. Is the edit better? –  dmckee Dec 17 '11 at 22:51
yes, great. Thx. –  ppuschmann Dec 21 '11 at 16:20

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.


share|improve this answer

Your Answer


