Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

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

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/

share|improve this answer

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
1  
700 = rwx------ –  ppuschmann Dec 17 '11 at 22:15
1  
@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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.