Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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. ;)

share|improve this question
    
Can you paste the result of running the command "mount" from the terminal. It should give you a list of all your mounts, their options etc. My guess is there are some permissions connected to the C-drive mount which remains when you are copying the files. (As NTFS permissions are different from normal *nix permissions your Linux system instead puts a sets of permission on the entire mount point.) –  andol Mar 5 '10 at 21:30
add comment

4 Answers

up vote 4 down vote accepted

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.

share|improve this answer
    
So would 002 be a good umask permission for me? –  Xeoncross Mar 14 '10 at 4:15
1  
If you want owner and group to be able to write, while preventing everyone else. It would be 777, while subtracting 2 on the last octet: 775. –  Warner Mar 15 '10 at 13:18
add comment

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:

rsync -rv --chmod=Doug=rx,Foug=r source/ dest/

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.

share|improve this answer
add comment
  1. You may change the way you mount the NTFS partition, so it shows the files on it rw. That way, when you copy them, they'll have w+.
  2. You may set a sticky bit to the directory where you usually copy the files to, so new files will be created with proper permissions there (I'm not really sure if it is going to work with copy).
  3. 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

    • seamless mode - you can run a windows applications on your linux desktop without the need to display the whole windows desktop.

The above approach worked very well for me for the last 4+ years.

Cheers

share|improve this answer
    
Really? I thought that the VirtualBox would cut the speed in half which really matters (even on a Quadcore) with Adobe Aftereffects and Photoshop. –  Xeoncross Mar 5 '10 at 21:31
    
I didn't see very big penalty (I do not use PS, but Visual Studio, running IIS on the same box and a SQL server). I need to admit that my tests show that VMware may be a little bit faster (has the same capabilities), but I kind of like the opensource nature of VBox. –  Sunny Mar 5 '10 at 21:38
add comment

The answer was to change the fstab mount file to not be so harsh on permissions.

sudo fdisk -l

then edit the file

sudo vim /etc/fstab

then I added the following line

/dev/sda1       /media/windows ntfs-3g defaults,locale=en_US.UTF-8 0 0

and last I remounted the fstab file

sudo mount -a

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.