0

I have one requirement in which when I create a directory I want to create it with 777 permission. I did all stuff but not able to do this, anybody knows how to do this? Then please share.

Suppose I have directory /home/sachin/dir.

Now I am creating one folder test under /home/sachin/dir.

mkdir /home/sachin/dir/test

It will create test folder with 775 permission which I do not want.

I don't want to use -m option with the mkdir command.

1
  • You have to use umask, added an answer Mar 4, 2015 at 7:30

1 Answer 1

0

You have to use umask command:

Execute this command for creating every file or directory with 777 permission for an interactive shell:

umask 000

If you want to make it permanent setting for a single user then execute following commands:

gedit ~/.profile

and add a new line as

 umask 000 

then save the file.

If you want to make it default setting for all users, then execute following commands:

sudo -H gedit /etc/profile

and add a new line as

 umask 000 

then save the file.

4
  • I want set umask for only test user then also i have add umask 000 into .profile file ?
    – sam
    Mar 4, 2015 at 8:23
  • I added umask 000 into /home/test/.profile and save the file, after that i create a file and that file was created with 644 permission. Any idea how to resolve it.
    – sam
    Mar 4, 2015 at 8:36
  • @sachin changes in ~/.profile require re-logging in to take effect.
    – muru
    Mar 4, 2015 at 9:40
  • I did, I reboot the server but still file not create with 777 permission.
    – sam
    Mar 4, 2015 at 11:39

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