Reputation: 917
I just want to disallow the user to view the contents of a folder but still allows the system/user to have read/write the files inside(when they have direct path)
Is that possible solely by using chmod?
Thanks!
Update: basically there a fedora 14 os where by the account user(not root group) cant view the contents of a folder but he can still access the files in it if he has direct path to the files. Im looking at the root to do a cmod to disallow viewing of the folder content(means user cant double click into the folder)
Upvotes: 2
Views: 4997
Reputation: 298
Yes, it is possible: chmod works like this
chmod u+w pathYouWantToHaveWritePermissionForUser/
chmod u-r pathYouWantToHaveNOreadPermissionForUser/
so for example you have the folder
chmod u+w /home/You/save/
chmod u-r /home/You/save/
test it with
nano /home/You/save/test
tip in something andsave the file. If you tip
cd /home/You/save/
ls
you will not be able to see any file in this directory. But you could read the file test
cat test
learn more about chmod reading the man page
Upvotes: 0
Reputation: 116277
Yes, this can be done. Note that for files, bits in rwx
permission mask mean: r
=read, w
=write and x
=execute. However, for directories, meaning is different, namely: r
=list directory, w
=create or delete file in directory, x
=descend to directory or access files or directories inside of it.
Knowing this, you can create directory structure which has your desired properties.
mkdir -p dir/subdir
sudo chmod 111 dir
sudo chmod 775 dir/subdir
With this, user will see that dir
exists, but will not be able to see its contents. However, he will be able to read existing files in dir
. Also, he will be able to cd dir/subdir
and have normal access inside of it.
Upvotes: 4