[SOLVED] Directories are created with chmod 777. Why?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
It's strange that I noticed my new directories with command mkdir are being created with permission 777 instead of 755. I don't recall any explicit changes I did to any of my configurations.
It's only happening on a particular mounted partition. If I create a directory in any of my Home directories its created correctly with permission 755.
Code:
$ cd ~
$ umask
0022
$ mkdir TestDir
$ ls -ld TestDir/
drwxr-xr-x 2 tuser tuser 4096 Jan 25 16:45 TestDir/
$ sudo umount /dc
$ ls -ld /dc
drwxrwxr-x 2 tuser tuser 4096 Jan 15 13:50 /dc
$ sudo mount /dev/sda2 /dc
$ ls -ld /dc
drwxr-xr-x+ 27 tuser tuser 4096 Jan 25 16:49 /dc
$ cd /dc
$ umask
0022
$ mkdir TestDir2
$ ls -ld TestDir2
drwxrwxrwx+ 2 tuser tuser 4096 Jan 25 16:51 TestDir2
Code:
$ grep '/dc' /etc/fstab
# /dc was on /dev/sda2 during installation
UUID=42ce5151-28f1-4567-b7b4-0b5a27e91721 /dc ext4 defaults 0 2
$ mount | grep 'dc\|svr'
/dev/mapper/mvg-svr on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)
/dev/sda2 on /dc type ext4 (rw,relatime,data=ordered)
The + on the ls output indicates there is an ACL on /dc. Based on the fact that /dc/TestDir2 also has an ACL, it looks like there is a default ACL involved (TestDir2 inherited a default ACL from /dc). ACLs can affect how the mode of a file appears. It can look like it's giving more permission than it actually is simply because the ACL can't be accurately reflected in the mode.
You can use the 'getfacl' command to look at the ACLs on /dc and /dc/TestDir2. That will give you a clearer picture of the permissions.
Location: Montreal, Quebec and Dartmouth, Nova Scotia CANADA
Distribution: Arch, AntiX, ArtiX
Posts: 1,364
Rep:
Hi ddenial,
Building on sgrlscz's advice, I would recommend you read up on the umask function. It doesn't always treat files and directories the same way and different distros can set default behaviour in different ways. It is an often misunderstood (at least partially) function.
I don't know what distro you are using, but :
... start with a search of any documentation it provides on how umask is configured by default.
Then, a look at the manual entry for umask could also be helpful:
Code:
man umask
The Arch Linux Wiki has (as usual) an excellent entry on umask - worth your time:
The + on the ls output indicates there is an ACL on /dc. Based on the fact that /dc/TestDir2 also has an ACL, it looks like there is a default ACL involved (TestDir2 inherited a default ACL from /dc). ACLs can affect how the mode of a file appears. It can look like it's giving more permission than it actually is simply because the ACL can't be accurately reflected in the mode.
You can use the 'getfacl' command to look at the ACLs on /dc and /dc/TestDir2. That will give you a clearer picture of the permissions.
Thanks. It really helped.
I don't know how ACL was set. This was the result of getacl
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.