Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
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.
I am running samba on my LAN. I have a guest directory which is readable and writable by everyone.
I want to do something on this directory and that is;
I want the users only to write and read in this directory , but they should not be able to delete any file from this directory.
i.e; If a user has created a file in this directory then he should not be able to delete or replace it.
someone has told me that you have to do something with "umask" but I don't know how ?
He told me that when a file is created you should change the "umask" to change its permssion, if you know something like that then please tell me.
The “umask” is a bitmap that sets the access properties for a file (or directory). You can use it to say if a given file can be read from (= directory contents listed), written to (=new files created) or executed (= directory contents can be accessed).
Each one of these can be set independantly for just one user, just one group, or everyone else.
First cd to the directory in question.
Code:
cd (directory)
Assuming that the files are created by group “user”, what you want to do is make the files read/writable to the user group:
Code:
chmod g=r *
The asterisk means “everything in this directory.” You can check this with
Code:
ls -l
(you want something like -***rw-*** where * can be anything).
Every file will then be marked as read-only and cannot be changed.
There's probably a way to set the default umask for new files, so you don't have to keep running this all the time.
I believe what you're asking for a the command ' create mode ' in samba. Goto to your smb.conf file and add ' create mode = XXXX ' where XXXX is the permissions you want to assign to the file. For example ' create mode = 0750 '.
but by doing this we cannot change the contents of the file cause it is readable but as the directory has "-rwxrwxrwx /tmp " option so we can still delete the file.
I want that once a file is created in the /tmp directory it should not be deleted.
"Remember I am asking this question for Samba not for local working"
I don't believe there's a Linux command (umask, chmod, etc) you can use to set this up. If a user can create a file, then he/she should be able to delete it. It is possible to set up an existing directory with existing files that users can write to (but not delete) but they won't be able to create a file either.
Remember that if a user can write to a file, he/she can delete all the contents of a file and save the empty file, wouldn't this be the same as deleting the file altogether?
Are you using a specialized file server? A NetApp appliance perhaps? You could probably use a setting in it to prevent you from deleting files no matter what, regardless of what the file/dir Linux permissions tell you.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.