Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In order to edit some files in Netbeans, I had to do a chmod 777 on the parent-folder. Reason being that anything else would result in Netbeans not wanting to accept the folder, as it could not be written.

Is there an other way to do this besides doing a chmod 777?

I'm on Ubuntu 9.10, using Netbeans 6.7.1

And after that, I manually have to give each file the needed rights. There should be an easier way, I just don't know it.

EDIT: I am running XAMPP and the files I'm trying to edit are in the htdocs folder.
I'm running Netbeans as my local user account, which is how it starts if I have it run from the applications-menu.

share|improve this question

migrated from stackoverflow.com Jan 30 '10 at 20:59

This question came from our site for professional and enthusiast programmers.

    
Which user owns the files and directories you are trying to edit? Which user are you running Netbeans as? –  Phil Ross Jan 30 '10 at 14:45
    
It is easier to provide help if you provide more details. I know that some folks think they need to change the protections of the GF app server installation. What directory are you chmod-ing? –  vkraemer Jan 30 '10 at 14:49
    
all the extra info I could think of. –  KdgDev Jan 30 '10 at 15:37

1 Answer 1

up vote 0 down vote accepted

There are 2 issues here, chmod and chown. Netbeans is running as you and the files hopefully are owned by you. If the files are owned by someone else, then they can chown the file. Here is how to change the ownership:

sudo chown your_account:your_account -R my_project

After the ownership has fixed then this is a very conservative chmod:

chmod 760 -R my_project

The first number is the owner, you own the file and 7 is read write execute. The middle number is the one that will govern group access rights, after the chown the group probably contains just you, but you could add another account to the group.

If the file is 666'ed, which is read write for everyone and lets say its written in a scripting language like python, then you can still execute it like this: python my_script.py . However a chmod 666 WILL NOT let you execute it like this: ./my_script.py. Seems like splitting hairs, but in the first command python is the executable and it is reading my_script (so it needs read access), in the 2nd case my_script.py is being executed.

The main threat that chmod and chown defend against is protecting your files from other accounts on the system. You probably are the only user on this system. However, when a hacker breaks in via a daemon process (like bind or postfix) then they will have the user privileges of that account. You don't want that hacker to be able to write executable code in your netbeans project that then could be executed by you. As long as the last block doesn't have a write bit then you shouldn't have to worry about this attack. This is why its common to see chmod 775 although chmod 770 would be more secure. Other daemons like Apache can still read and execute your NetBeans project with a chmod 775 and this might be important if its a PHP project being executed by Apache.

share|improve this answer
    
+1 for the answer overall, but you're incorrect about one thing: The first number is not for root (root is almighty, doesn't need permission). First number is for chown, second is for chgrp, third is for other. So 760 = owner can do everything, group can read/write, and anybody else has no rights. –  Michael Moussa Jan 30 '10 at 17:52
    
Other mike, you are correct sir. I have edited it, thank you. –  Michael Brooks Jan 30 '10 at 18:10

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.