Directory ownership or permissions inside another directory
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.
Directory ownership or permissions inside another directory
First, some background knowledge to give perspective on my question:
Here's the situation. I'm running Joomla content manager for a school, and I let the teachers work on their own pages. I installed an add-on to allow teachers to upload files (pictures, documents, etc.) to a place on the server which resides at /srv/www/htdocs/files/teachers/teacheruploads/"teachers name"/
However, and I did not see this happening, teachers are using the built in media uploader (instead of my add-on) and the files are being stored (messily) on the default media directory, which is /srv/www/htdocs/files
Here's the Linux based question, and I THINK I already know the answer, but I'm hoping for a miracle.
Question:
Is it possible to restrict file upload to a directory by user(s), while allowing the same user(s) to upload files to a directory inside the directory I'm wishing to restrict? Whether it be through file permissions or file ownership?
Yes, you can remove write permission from a directory while allowing writes to subdirectories within it. It's done all the time. Consider that you don't have write permission in /home but do have write permission in /home/slyfox (or whatever your actual home directory might be).
Is it possible to restrict file upload to a directory by user(s), while allowing the same user(s) to upload files to a directory inside the directory I'm wishing to restrict? Whether it be through file permissions or file ownership?
Yes, it's possible. Simply remove write permission (for group and others) for the all the parant directories, using command:
Quote:
chmod 755 <directory__name>
In addition, you can set sticky bit permission on those directories, so in that case, files inside dir. can be deleted by the owner of the file, the owner of the directory or root. This prevents a user from deleting other users files from public directories. To do this:
Thank you for the responses. The example regarding /home/"user" makes so much sense I'm a little bothered I didn't think of it. I suppose that's why I post in the newbie section.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.