Does the parent directory have permissions on the subdirectory? [Linux]

Source: Internet
Author: User

Source of the problem:

Log on to the server (a server account in the lab), want to create a file in the current directory, but prompt "file system Read Only", unable to create the file. by ls-l

View the current user's permissions in the current directory and discover that they have RWX permissions. So I thought maybe it was because I didn't have W permissions in my parent directory that I couldn't create a file in the current directory.

But found in the parent directory I also rwx permissions ... (Finally, I feel the problem may be that the server administrator has write protection to the hard drive)

So I did the following experiment to verify that the permissions of the parent directory to subdirectories have no effect? "For example, I have no write permission in the parent directory (TESTDIR), I am in the current directory

(testdir/abc/) Can I perform a write operation?

LxW ~$ls-LDtestdir/DRWXRWXR-X3LxW LxW4096Dec -  the:Tentestdir/LxW~$chmod  -testdir/LxW~$ls-LDtestdir/ Dr-X------ 3LxW LxW4096Dec -  the:Tentestdir/LxW~$ CD testdir/LxW testdir$Touchparentfile #合理, no w permission for TestDirTouch: CannotTouch' parentfile ': Permission Deniedlxw testdir$ls-Ltotal8DRWXRWXR-X2LxW LxW4096Dec - Ten: -ABC-rw-rw-r--1LxW LxW4Dec -  the:TenTxtlxw testdir$ CD ABC/LxW abc$lsLxW abc$TouchChildfile #父目录虽然没有w权限, but as long as I have access to the current directory (with x permission), I am able to follow my permissions in the current directory. LxW abc$lsChildfile

So, after the above authentication, although the parent directory does not have the W permission, but as long as I can enter the current directory (with x permission), I can follow my permissions in the current directory, do

Operation.

Now I leave the testdir/directory with only X permissions:

LxW ~$chmod  -testdir/LxW~$ ll-d testdir/ D--x------ 3LxW LxW4096Dec -  the:TenTestDir//LxW ~$ CD testdir/LxW testdir$ls #合理, no r permission ls: Cannot open Directory.: Permission Deniedlxw testdir$ ll-d ABC #虽然我在testDir/no r permission to see what files it has, but if I know beforehand what files it has, I can view these files through LS. DRWXRWXR-X2LxW LxW4096Dec - Ten: -abc/LxW testdir$ ll txt #同上-rw-rw-r--1LxW LxW4Dec -  the:TenTxtlxw testdir$Toucha #合理, no W permissionTouch: CannotTouch' a ': Permission Deniedlxw testdir$ cd Abclxw abc$lsChildfilelxw abc$ ll-LD. DRWXRWXR-X2LxW LxW4096Dec - Ten: -./LxW abc$TouchChildFile2 #虽然我在父目录中没有rw权限, but as soon as I get to the directory (x permission), I can follow my permissions in the current directory. LxW abc$ls-Ltotal0-rw-rw-r--1LxW LxW0Dec - Ten: -Childfile-rw-rw-r--1LxW LxW0Dec - Ten: -ChildFile2

So, through the above experiment, I think that as long as the parent directory has x permissions, the permissions of the parent directory and the permissions of the subdirectories are not directly related and do not affect each other .

Finally, the following example further illustrates:

LxW ~$chmod  -testdir/LxW~$ls-LDtestdir/ drw------- 3LxW LxW4096Dec -  the:Tentestdir/LxW~$ CD testdir/#合理, no X permissionsBash:cd:testDir/: Permission Deniedlxw~$ls-L testdir/#有r权限ls: Cannot access testdir/Txt:permission deniedls: Cannot access testdir/abc:permission deniedtotal0D?????????            ? ? ? ? ?ABC-?????????            ? ? ? ? ?txtLxW ~$ cd testdir/abcbash:cd:testDir/Abc:permission denied

Last statement, I have RWX permission to the ABC directory, I have RW permission on TestDir, but I can't enter TESTDIR/ABC ( the permissions of the parent directory affect the

subdirectories , because I don't have X permissions on TestDir.

If you have any different views, you are welcome to communicate with me.

Does the parent directory have permissions on the subdirectory? [Linux]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.