LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   file permissons (https://www.linuxquestions.org/questions/linux-newbie-8/file-permissons-691467/)

mahmoud 12-18-2008 07:56 AM

file permissons
 
Hi
does anyone know what permision i need to give a file to allow users to
copy or open but cant delete the file or do i need to give the permisions to the folder

TB0ne 12-18-2008 09:09 AM

Quote:

Originally Posted by mahmoud (Post 3379909)
Hi
does anyone know what permision i need to give a file to allow users to
copy or open but cant delete the file or do i need to give the permisions to the folder

That would be read access, but you don't say how deep. Do you want owner read only, owner-group read only, or world read only?

chmod 400 (owner only)
chmod 440 (owner-group)
chmod 444 (everyone)

"man chmod" for more information.

mahmoud 12-18-2008 10:02 AM

thanks just what i wanted

kapilbajpai88 12-18-2008 11:19 AM

Hi There,

I think Chmod will not work properly, if permissions are going to be assigned at user level.
I mean to say that if a user is trying to alter permissions for another user, then chmod will let you do so.
Anyways, this is the detailed description regarding permissions at different levels :
400 read by owner
040 read by group
004 read by anybody (other)
200 write by owner
020 write by group
002 write by anybody
100 execute by owner
010 execute by group
001 execute by anybody

Hope this might help you....

Kapil.

rajeshkerala 12-21-2008 01:34 AM

I think putting that file in /tmp folder will do the job. /tmp being a sticky directory wont allow users to delete the file, but they can copy or read the file..
Is it correct what I am saying...?

bdox 12-21-2008 07:53 AM

Quote:

I think putting that file in /tmp folder will do the job. /tmp being a sticky directory wont allow users to delete the file, but they can copy or read the file..
Is it correct what I am saying...?
I don't think it's a good idea. the files could be eventually deleted as that directory is meant for temporary files and some automatic programs delete files there periodically...

saagar 12-24-2008 06:30 AM

Ok, then create a directory with sticky bit..
chmod 1755 <directory name>

bdox 12-24-2008 01:15 PM

Yes, I think the best is to create a forder and as root do:
chmod 444 <directory name>
...

Telemachos 12-24-2008 03:51 PM

Whether or not a file can be deleted has to do with the permissions of the directory it's in, not the file itself. You could create a file, belonging to root and set its permissions to 000, but if it's in my $HOME directory, I can delete it.
Code:

root /home/telemachus # chown root:root zero
root /home/telemachus # chmod 000 zero
root /home/telemachus # ls -l zero
---------- 1 root root 0 2008-12-24 16:48 zero
root /home/telemachus # exit
exit
telemachus ~ $ rm zero
rm: remove write-protected regular empty file `zero'? y
telemachus ~ $ ls
bin    changes      Desktop  firstclass  images_backup  lib  musica    storage
books  debian_stuff  firefox  iliumSvn    kernels        man  practice  tint2

So, my point is that you need to think more about the permissions of the directories where you will store the files, not just the files themselves.
See here for more: http://www.albany.edu/faculty/gms/ho...rmissions.html

visitnag 12-24-2008 09:18 PM

I go with Telemachos

saagar 12-24-2008 10:13 PM

Mr.Telmachos,
So what do u suggest as the ideal solution for the question generated by mahmoud..Is n't that putting the file in a directory with sticky bit added to it?

divyashree 12-25-2008 12:14 AM

hey mahmoud,use sticky bit on those files

sumit dash 12-25-2008 12:26 AM

hi
 
Hi frnd,

Simply use sticky bit all users can read and add but canot delte any file from it


All times are GMT -5. The time now is 07:26 PM.