How to create a directory with 777 permissions?

I want to create directory with permission 777.

The code below is creating the directory, but not with permissions I asked for.

section .text
global _start:
             mov rax,83 ;syscall number for directory
             mov rdi,chaos ; dir name
             mov esi,00777Q ;permissions for directory
             mov rax,60
             mov rdi,0
section .data
           chaos:db 'somename'

1 Answers How to create a directory with 777 permissions?

Here's man 2 mkdir:

The argument mode specifies the mode for the new directory (see inode(7)). It is modified by the process's umask in the usual way: in the absence of a default ACL, the mode of the created directory is (mode & ~umask & 0777).

Basically, both your program and your user can veto each permission bit:

  • You can say which bits you are comfortable with by passing them to mkdir
  • The user can say which bits they are comfortable with by setting the umask
  • Only bits that you both agree on will be set on the final directory.


  • If you run umask 0000 before running your program, your directory will be 0777.

  • If you run umask 0027 your directory will be 0750.

  • If you want to force your directory to be 777 against the user's wishes, you have to chmod("somename", 0777) in a separate step.

4 months ago