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.
Hi all, I am a newbie.
If I have /media/dir1 shows as follows:
drwxr-x--- root root *** dir1
And 'mydir' is a subdirectory of 'dir1':
drwxrwxrwx root root *** mydir
If now someone logged in as 'user',
can he accesses (goes into) 'mydir' by issuing 'cd /media/dir1/mydir'?
The permission for 'dir1' denies his access to /media/dir1,
but the permission for 'mydir' allows his access to 'mydir' which is actually '/media/dir1/mydir'!
The reason is that to access a file, you have to have access to all
of the parent directories. That is what the x permission means on
a directory. So unless users have x permission for /, /media and
/media/dir1, they will not have access to files in /media/dir1 even
if those files have r permission.
The reason is that to access a file, you have to have access to all
of the parent directories. That is what the x permission means on
a directory. So unless users have x permission for /, /media and
/media/dir1, they will not have access to files in /media/dir1 even
if those files have r permission.
I say yes.
please checkout, you can have write permissions on pendrives.
so, What i was saying is ...
it doesn't matter the permissions of parent directory. if a child directory has drwxrwxrwx then that was enough for the user to access.
but that user must know full path to that child directory (if he don't have read permissions of parent ).
702 does not give execute permissions, so the user cannot open the directory.
Directories must be readable and executable r-x (5) for each type of user to access them.
x alone is not enough because you can't read.
You must always have read permissions as a basic rule, and execute if it's a directory. Write is optional.
Ok then, it can possible if a root user give 777 for a particular directory.
so owner of parent directory, child directory was root. But every user can modify it.
so even if /media,/media/dir1 has read permissions, a user can access the /media/dir1/mydir1
On a directory 'x' controls access to the inodes of the files/subdirectories contained within it. Strictly speaking you don't need either 'r' or 'w' to access the files within a directory so long as you already know their names.
Code:
bash-3.1$ mkdir testdir
bash-3.1$ echo wibble >testdir/file
bash-3.1$ chmod 600 testdir/file
bash-3.1$ chmod 100 testdir
bash-3.1$ ls -ld testdir
d--x------ 2 gazl users 4096 2010-02-21 16:19 testdir
bash-3.1$ ls testdir
ls: cannot open directory testdir: Permission denied
bash-3.1$ ls testdir/*
ls: cannot access testdir/*: No such file or directory
bash-3.1$ ls -l testdir/file
-rw------- 1 gazl users 7 2010-02-21 16:19 testdir/file
bash-3.1$ cat testdir/file
wibble
bash-3.1$ echo wobble >testdir/file
bash-3.1$ cat testdir/file
wobble
bash-3.1$
You need 'r' on a directory if you want to list its contents.
You need 'w' on a directory if you want to create, rename or delete files in it.
Now, look what happens when you remove 'x', and only have 'r'
[code[
bash-3.1$ chmod 400 testdir
bash-3.1$ ls -ld testdir
dr-------- 2 gazl users 4096 2010-02-21 16:19 testdir
bash-3.1$ ls testdir
file
bash-3.1$ ls -l testdir/file
ls: cannot access testdir/file: Permission denied
bash-3.1$
[/code]
... in this example you can ls, but not ls -l (the stats for the file are stored in the inode, and 'x' controls the access to that).
Have a play for yourself, its quite interesting what you can and cannot do with various combinations of permissions, and well worth investing 5 minutes to learn how it all hangs together.
Thank you very much for all your replies especially for that of smoker, raju.mopidevi, and GazL.
I test myself and it seems that the answer of smoker is right.
All that I learned is that if in /home/, there exists a directory
Then no user (except for root) can 'r' or 'w' or 'x' any entry which succeeds the dir. tree /home/rootsdir/.
Is this right? I just want an absolute answer for some security reasons.
I am wondering that how can raju.mopidevi's example
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.