-2

So by default my / directory is chmod 555. I ran the following to test something out:

sudo chmod 777 /
mkdir /dss
sudo chmod 555 / # reset permissions

if I run stat /dss then it shows

  File: ‘/dss’
  Size: 6               Blocks: 0          IO Block: 4096   directory
Device: 10302h/66306d   Inode: 5802557     Links: 2
Access: (0755/drwxr-xr-x)  Uid: ( 1001/ssm-user)   Gid: ( 1002/ssm-user)
Access: 2021-06-30 22:01:44.478434800 +0000
Modify: 2021-06-30 22:01:44.478434800 +0000
Change: 2021-06-30 22:01:44.478434800 +0000

I expected /dss to inherit 777 permissions from / at the time it was created? And if I create any subdirectories under /dss, they're all 755. What's happening here?

user3613290
  • 461
  • 6
  • 18
  • 2
    There's no permission inheritance in Unix. – Barmar Jun 30 '21 at 22:06
  • 2
    [so] is for programming questions, not questions about using or configuring Unix and its utilities. [unix.se] or [su] would be better places for questions like this. – Barmar Jun 30 '21 at 22:06
  • 1
    The permissions on the created directory depend on your `umask` – Stephen P Jun 30 '21 at 22:07
  • With certain settings the GID will be inherited from the parent instead of the creating process. And a directory can have default ACLs that are applied to created files and subdirectories. – Barmar Jun 30 '21 at 22:09

1 Answers1

3

You are matching two different things in this question, chmod is a command to set the permissions for a specific path or file, you can do it recursively in differents ways but that you are asking is umask value that determinants the permissions given to a file when is created.

If you want to check the value setting, you have to execute the command “umask”, this could tell you the value as default that the user has to create files.

If you want to change the umask value you can run the following command to set it.

umask 022

Keep in mind that the numbers that are you described in the command above are the permissions that won't give to the file, so, in this case, will be generated with 755.

Please refer to the next table.

Number Permission 4 read 2 write 1 execute

This command isn’t permanent, once you logout this will be lost and set as default, if you want to change the value in a permanent way you need to set up in “/etc/profile” or “bashrc” and add the command above, you can refer to[1].

BR.

[1] https://www.cyberciti.biz/tips/understanding-linux-unix-umask-value-usage.html

Nadia Espinosa
  • 358
  • 1
  • 9