One of my favorite things about Linux is also the most annoying - file system permissions. In production machines and web servers I love how everything is so secure and locked down - but on development machines it really slows me down. I'll give one example out of the many that I discover weekly.
Like most people, I dual-boot Ubuntu and Windows so I can continue using the Adobe CS4 suite. I often design web themes and other things while I'm still using windows. Later I'll boot into Ubuntu to take the themes and write the backend PHP for them. After mounting the windows C: drive partition I can copy the template files over so I can begin editing them.
However, thanks to Linux desire to protect me I find that after coping the files I end up with a totally locked set of files where even I don't have read-write permissions. So after carful consideration about the tremendous risks that the HTML files pose to me - I chmod them so that I and apache can begin using them.
Now given, the chmod process isn't that hard - but after you chmod enough files per day you get sick of doing it. I'm constantly creating, fetch, editing, and removing files from my user, git repos, php, or other random processes. This is a personal development machine after all. Everything changes on a day by day basis.
So my question is, how can I get linux to relax about what I'm doing with my HTML/JS/PHP/TXT/SQL/etc. files so that I can work faster without constantly stopping to chmod things?
I pinky-promise I won't hack into my account with an HTML file. ;)
umask
sets the default permissions for the user creating files.This is set in the shell environment. For bash system wide, that's
/etc/profile
. Or, you can set it for the user in~/.bash_profile
or~/.bashrc
depending on how the shell is executed.Update:
I recommend when you copy the files over you use rsync instead of setting your umask. You can then use the
--chmod
argument to rsync to get the permissions you want. I think something like:This might be better than umask because it is a more localized solution.
You can also make a script that sets all the permissions correctly. The advantage of doing this is that the script will be useful in your production environment.
My favorite: do not dual-boot. The loss of speed using windows in a virtual machine (I use virtualbox) is very small. And VirtualBox provides you with these goodies:
supports hardware video acceleration - i.e. if you have proper drivers, your windows VM can have 3d rendering as well (if you need it)
provides shared folders - i.e. directory(ies) on your host OS, which are accessible from your VM, so you can share files
The above approach worked very well for me for the last 4+ years.
Cheers
The answer was to change the fstab mount file to not be so harsh on permissions.
then edit the file
then I added the following line
and last I remounted the fstab file
Thanks to these two resources. Now all the files I create are using the same "defaults" as what my current user is running (I think).
umask
is also an option you can set on the mount to control copy permissions of files.