0

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.

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

2 Answers 2

6

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

3
4

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/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .