[Novalug] How to change a file's permission question

Jon LaBadie novalugml@jgcomp.com
Tue Aug 28 12:24:05 EDT 2012


On Tue, Aug 28, 2012 at 11:52:15AM -0400, Peter Larsen wrote:
> Charlie,
> If you're looking to make a permanent change in the default attributes,
> you need to look at umask. Umask is a bit "strange" unless you're a
> bit-master. It is a negative mask of the default permission bits. For
> instance:
> 
> $ umask
> 0002
> 
> This reports the current mask as 0002 - this means for standard files,
> the default access would become 664 (X (execute) is ignored). 
> 
> Of course you could "cheat" and get the mask printed in text:
> 
> $ umask -S
> u=rwx,g=rwx,o=rx
> 
> Again, x is ignored. If you're seeing different attributes, the file
> most likely already exists and chmod is your only option.
> 

True when creating ordinary files.  When creating directories execute
permission setting in the umask does affect the result.

> On Mon, 2012-08-20 at 10:24 -0400, cmhowe@patriot.net wrote: 
> > List,
> > 
> > A file has been created by a process such that
> > 
> >   ls-l /home/chasmhowe/Documents/file-a
> > 
> > yields
> > 
> >   -rw-r--r-- /home/chasmhowe/Documents/file-a
> > 
> > What command do I use that so that
> > 
> >   ls-l /home/etc
> > 
> > yields
> > 
> >   -rw-r--rw-r
> > 
> > with the result that I can edit it by using
> > 
> >   gedit /home/chasmhowe/Documents/file-a
> 
> This is where you lost me a bit. Are you asking how to change permission
> on all user home directories, so that you as another user can read/write
> their files?  If that's your question, your permission set will not
> work. For directories, X (execute) means that you can access the
> directory - R (read) means that you can list the content of it. So you
> need to set BOTH R and X to make it behave like a normal directory. You
> can hide the content by just giving an X, which allows you to access
> files if you know the full path and don't need to use "ls" to find it.
> But gnome and your graphical file managers will not be able to list the
> content then.
> 
> By default, as I indicated above, you will get RW/RW for you and the
> group - and the world can READ. If you create directories, the umask
> adds the X that's otherwise ignored, so that you can actually access it.
> 
> Setting the umask is a bit hard using codes - so -S comes to your
> rescue. For instance, if you don't want the world and your group to have
> any rights to your files by default, you would set the umask this way:
> 
> $ umask -S g=,o=
> u=rwx,g=,o=
> 
> It's a bit easier than having to calculate the reverse mask:
> 
> $ umask 0077
> 
> But remember, umask only works for NEW files. 
> 
> If you're trying to share files between users, this is not the way to
> go. In that case you need to look at "setuid/setguid". By setting this
> bit (+s) on a directory, files created gets owned by that user/group.
> This is a way of enforcing a common group ownership so a group of users
> can manage the same files.
> 
> > 
> > Or am I asking a question that isn't quite right?
> 
> If I didn't cover what you were looking for, please ask again.
> 
> 
> -- 
> Best Regards
>   Peter Larsen
> 
> Wise words of the day:
>          Why use Windows when you can have air conditioning?
>          Why use Windows, when you can leave through the door?
> 	-- Konrad Blum



> _______________________________________________
> Novalug mailing list
> Novalug@calypso.tux.org
> http://calypso.tux.org/mailman/listinfo/novalug

>>> End of included message <<<

-- 
Jon H. LaBadie                  novalugml@jgcomp.com
 11226 South Shore Rd		(703) 787-0688 (H)
 Reston, VA  20190		(609) 477-8330 (C)



More information about the Novalug mailing list