# Permissions at creating directory

**URL:** <https://www.ruby-forum.com/t/permissions-at-creating-directory/150886>\
**Category:** Ruby\
**Created:** [October 14, 2008, 6:06pm UTC](https://www.ruby-forum.com/t/permissions-at-creating-directory/150886 "2008-10-14T18:06:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cc9497/32.png) [@Kless](https://www.ruby-forum.com/u/Kless)\
**Post date:** [October 14, 2008, 6:06pm UTC](https://www.ruby-forum.com/t/permissions-at-creating-directory/150886/1 "2008-10-14T18:06:04Z")

</div>

Why a new directory is ignoring my permissions?

Dir.mkdir(‘foo’, 711)

It’s created with 755, the permissions by deafult of my system. My  
umask is to 0022.

---

<div class="post-metadata">

**Author:** ![Kless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cc9497/32.png) [@Kless](https://www.ruby-forum.com/u/Kless)\
**Post date:** [October 14, 2008, 8:15pm UTC](https://www.ruby-forum.com/t/permissions-at-creating-directory/150886/2 "2008-10-14T20:15:25Z")

</div>

Instead of 711, try 0711.

~mm

---

<div class="post-metadata">

**Author:** ![Kless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cc9497/32.png) [@Kless](https://www.ruby-forum.com/u/Kless)\
**Post date:** [October 14, 2008, 8:51pm UTC](https://www.ruby-forum.com/t/permissions-at-creating-directory/150886/3 "2008-10-14T20:51:19Z")

</div>

On 14 oct, 19:14, Michael M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Instead of 711, try 0711.  
> I had tried too as with 0700 but nothing.

---

<div class="post-metadata">

**Author:** ![Kless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cc9497/32.png) [@Kless](https://www.ruby-forum.com/u/Kless)\
**Post date:** [October 15, 2008, 10:36am UTC](https://www.ruby-forum.com/t/permissions-at-creating-directory/150886/4 "2008-10-15T10:36:56Z")

</div>

Kless wrote:

> Why a new directory is ignoring my permissions?
> 
> Dir.mkdir(‘foo’, 711)
> 
> It’s created with 755, the permissions by deafult of my system. My  
> umask is to 0022.

So what’s “your system”? (i.e. OS and Ruby version)

It Works For Me [TM]. This is Ubuntu Dapper with its default Ruby:

irb(main):001:0\> RUBY\_VERSION  
=\> “1.8.4”  
irb(main):002:0\> “%o” % File.umask  
=\> “22”  
irb(main):003:0\> Dir.mkdir “foo1”  
=\> 0  
irb(main):004:0\> `ls -ld foo1`  
=\> “drwxr-xr-x 2 candlerb candlerb 4096 2008-10-15 09:31 foo1\n”  
irb(main):005:0\> Dir.mkdir “foo2”, 0700  
=\> 0  
irb(main):006:0\> `ls -ld foo2`  
=\> “drwx------ 2 candlerb candlerb 4096 2008-10-15 09:31 foo2\n”  
irb(main):007:0\>

but I get the same with 1.8.6p114 built from source under Ubuntu Hardy.

What happens if you try to chmod the directory after creating it? What  
filesystem are you trying to create this directory in?

If you have a Linux box but are creating files in a mounted MS-DOS  
filesystem (typically the case for a memory stick) then you’ll get the  
same Unix mode bits for everything, as the filesystem doesn’t store  
them.

HTH,

Brian.

---

<div class="post-metadata">

**Author:** ![Kless](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/cc9497/32.png) [@Kless](https://www.ruby-forum.com/u/Kless)\
**Post date:** [October 15, 2008, 4:20pm UTC](https://www.ruby-forum.com/t/permissions-at-creating-directory/150886/5 "2008-10-15T16:20:31Z")

</div>

On 15 oct, 09:37, Brian C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> It Works For Me [TM]. This is Ubuntu Dapper with its default Ruby:  
> =\> 0  
> filesystem (typically the case for a memory stick) then you’ll get the  
> same Unix mode bits for everything, as the filesystem doesn’t store  
> them.
> 
> HTH,
> 
> ## Brian.
> 
> Posted viahttp://www.ruby-forum.com/.

Thanks! You gave me the idea.

The problem is that I’m trying to create a subdirectory, anything as  
‘./foo/bar’. If it’s tryed in irb, it gives a failure.

But I was calling it since a JRuby program where it’s created  
correctly except for the mode.
