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!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
Ill ask my question first and explain it more below..
I have a folder with 5 files in it. The folder is called testfolder. What I want to ensure is that, even though users have access to the folder they cannot rename it.
But they can still go into the testfolder, and rename and modify the files inside it. All I want is just to make sure the folder cannot be renamed without taking away their access to the contents inside. Is there a way to do this?
The users trying to rename of course wont be root. Is there a chown or chmod setup to do this?
I dont want them to lose their access to the folder's contents. I just dont want the folder renamed.
well, I can give you a limited solution, but it disables also renaming and creating of new files.. /:
chattr +i testdir
Heres a man grab:
A file with the `i' attribute cannot be modified: it can_
not be deleted or renamed, no link can be created to this
file and no data can be written to the file. Only the
superuser or a process possessing the CAP_LINUX_IMMUTABLE
capability can set or clear this attribute.
For some reason, some of those properties are inherited by the files inside the dir. It would be perfect if it worked correctly. Note, even root doesnt have any more access to them under the i. So, youll have to remove the attribute first with chattr -i testdir.
Modifying the files under the dir worked when I tried it, but not much else.. /:
just figured why it doesnt work as its supposed to. Seems like the i parameter cannot be used on directories, so it applies it to the files also or sumthing.. d:
The reason I need this is, I dont want to give some people access to the box, but I have setup a page made in php that detects certain directories to change their options.. but if they rename the directories the script goes to crap :P
and i cant just, tell them not to rename because these arent close friends, they are practical strangers im helping out
Did quite a heap of testing and came up with a solution:
If you create a dir with the chmod +t set, and another dir under that with +t also, but also chmod 777, the second dir cannot be moved, but stuff under it functions normally to the ones owning them. MAke any sense? (; example:
Yeah leaving the above directory completely vulnerable is not a good idea :\ . But that directory would probably be empty besides the protected folder(s).. so maybe it might be okay. Could someone -r delete foodir and thus testfir inside?
Don't worry about using the sticky bit (chmod +t), making any dir that you don't want to let anyone edit chmod 777 is not a good idea. All you need to do is make the directory (folder) that testfolder is located in, say "above", not writable by those that you don't want to write to it. Like this:
||| above --> this is not writable - chmod 755 - owned by root
||| -- testfolder --> this is writable - chmod 777 - owned by anybody you like, even root
|||||| -- user_dirs_&_files
This way, users wont be able to edit anything, including the name of dirs, in the "above" dir, but will be able to create & edit in "testfolder".
lol.. why didnt I think of that.. alot easier indeed. Guess I just missed the obvious, sorry for that.. (:
If you want so that the lowest folder can contain files by many users but they can only edit files they own themselves (while still preserving the chmod 777), then use the stickbit for the dir, but otherwise it goes un-needed with the above structure.