LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 01-25-2018, 05:27 AM   #1
ddenial
Member
 
Registered: Dec 2016
Distribution: CentOS, Fedora, Ubuntu
Posts: 359

Rep: Reputation: 56
Directories are created with chmod 777. Why?


Hello,

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)

What could be wrong?

Appreciate any help. Thanks

Last edited by ddenial; 01-25-2018 at 05:30 AM.
 
Old 01-25-2018, 06:54 AM   #2
sgrlscz
Member
 
Registered: Aug 2008
Posts: 123

Rep: Reputation: 84
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.
 
2 members found this post helpful.
Old 01-25-2018, 07:21 AM   #3
Rickkkk
Senior Member
 
Registered: Dec 2014
Location: Montreal, Quebec and Dartmouth, Nova Scotia CANADA
Distribution: Arch, AntiX, ArtiX
Posts: 1,364

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
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:

    https://wiki.archlinux.org/index.php/Umask

Cheers and let us know how you make out !

Last edited by Rickkkk; 01-25-2018 at 07:23 AM.
 
1 members found this post helpful.
Old 01-25-2018, 07:27 AM   #4
ddenial
Member
 
Registered: Dec 2016
Distribution: CentOS, Fedora, Ubuntu
Posts: 359

Original Poster
Rep: Reputation: 56
Quote:
Originally Posted by sgrlscz View Post
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

Code:
$ getfacl /dc
getfacl: Removing leading '/' from absolute path names
# file: dc
# owner: tuser
# group: tuser
user::rwx
user:tuser:rwx			#effective:r-x
group::r-x
group:tuser:r-x
mask::r-x
other::r-x
default:user::rwx
default:user:tuser:rwx
default:group::rwx
default:group:tuser:rwx
default:mask::rwx
default:other::rwx
After some web search, and with the following command, the problem is gone.
Code:
$ setfacl -b /dc

$ getfacl /dc
getfacl: Removing leading '/' from absolute path names
# file: dc
# owner: tuser
# group: tuser
user::rwx
group::r-x
other::r-x
Thanks
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Always chmod 777 akbartrinanda Linux - Newbie 3 03-25-2016 12:59 PM
chmod 777 664 zerocool22 Linux - Server 7 06-03-2008 06:58 AM
Is it safe to chmod 777 Navaboy Slackware 4 03-24-2005 06:54 AM
CHMOD in shell : chmod 777 /usr/ <---is that right? cpanelskindepot Programming 5 07-16-2004 05:37 AM
chmod 777 /* ziggamon Linux - Newbie 2 09-25-2003 11:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:57 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration