NetBeans "Cannot lock read only error"

NetBeans "Cannot lock read only error"

Author
Discussion

TedLeveTT

Original Poster:

160 posts

87 months

Thursday 23rd March 2017
quotequote all
Hi all,

Went to edit some PHP code earlier on and Netbeans will not allow it. I have chmodded the folders with full permissions but Netbeans won't have it. I am on Ubuntu. I will attach a screenshot below. Any help will be greatly appreciated...

maffski

1,866 posts

158 months

Thursday 23rd March 2017
quotequote all
Does something else have a lock on the file? I don't use linux much myself but lslocks or fuser should tell you if there is a conflicting lock.

TedLeveTT

Original Poster:

160 posts

87 months

Thursday 23rd March 2017
quotequote all
maffski said:
Does something else have a lock on the file? I don't use linux much myself but lslocks or fuser should tell you if there is a conflicting lock.
Thanks, but no luck. I am not particularly familiar with Linux myself so troubleshooting is difficult.

TonyRPH

12,963 posts

167 months

Friday 24th March 2017
quotequote all
It says the file is read only, so do you have ownership of said file(s) and folder(s)?

This assumes you are developing as a non privileged user.

If the files reside in a web folder (e.g. /var/www), then the owner is likely to be www-data.

You could add your username to the www-data group, and then ensure that all files have 664 and folders 775 permissions.

To add yourself to the group (off the top of my head) gpasswd -a <username> <groupname>

NOTE - if this is a production server - DO NOT DO THIS!!

If it's just your own dev box then it's fine.

It could also be apparmor causing this.

Are you running apparmor?

Again, if this is NOT a production machine - you can simply disable and remove apparmor.

AppArmor can be disabled or removed as follows:
Disable AppArmor using the following commands:

# /etc/init.d/apparmor stop
# /etc/init.d/apparmor teardown
# update-rc.d -f apparmor remove


Then, restart the server.
Remove the apparmor package with your package manager:

apt-get remove apparmor

^^^ stupid forum won't let me add a second batch of code tags.


Edited by TonyRPH on Friday 24th March 11:36

TedLeveTT

Original Poster:

160 posts

87 months

Friday 24th March 2017
quotequote all
TonyRPH said:
It says the file is read only, so do you have ownership of said file(s) and folder(s)?

This assumes you are developing as a non privileged user.

If the files reside in a web folder (e.g. /var/www), then the owner is likely to be www-data.

You could add your username to the www-data group, and then ensure that all files have 664 and folders 775 permissions.

To add yourself to the group (off the top of my head) gpasswd -a <username> <groupname>

NOTE - if this is a production server - DO NOT DO THIS!!

If it's just your own dev box then it's fine.

It could also be apparmor causing this.


Are you running apparmor?

Again, if this is NOT a production machine - you can simply disable and remove apparmor.

AppArmor can be disabled or removed as follows:
Disable AppArmor using the following commands:

# /etc/init.d/apparmor stop
# /etc/init.d/apparmor teardown
# update-rc.d -f apparmor remove


Then, restart the server.
Remove the apparmor package with your package manager:

apt-get remove apparmor

^^^ stupid forum won't let me add a second batch of code tags.


Edited by TonyRPH on Friday 24th March 11:36
Thanks for the help, but I managed to sort it this morning. I simply used the terminal "mv" command to move it to another folder, I used Documents then I moved it back and hey presto! Thanks very much for the help though.


Edited by TedLeveTT on Friday 24th March 19:02

TonyRPH

12,963 posts

167 months

Friday 24th March 2017
quotequote all
TedLeveTT said:
Thanks for the help, but I managed to sort it this morning. I simply used the terminal "mv" command to move it to another folder, I used Documents then I moved it back and hey presto! Thanks very much for the help though.
No worries - I had to read your reply about 5 times to find your response, as you replied inside my quote.

Odd that just moving the files around fixed it, unless permissions changed in the process.


TedLeveTT

Original Poster:

160 posts

87 months

Friday 24th March 2017
quotequote all
TonyRPH said:
No worries - I had to read your reply about 5 times to find your response, as you replied inside my quote.

Odd that just moving the files around fixed it, unless permissions changed in the process.
Woops, don't know how that happend, sorry about that! Yes well i guess by moving the folder into My Documents it changed the permissions? The original file was unzipped from my google drive. Once again, thanks for the help! thumbup