3

I have ubuntu 16.04 and I installed Geany using Ubuntu Software Centre. I need to edit some php and js files which happen to be in root directories. So when I try to save the changes in Geany, it generates following error:

Error opening file '/var/www/html/project1/team/team.php': Permission denied

The file on disk may now be truncated!

How can I make Geany to edit and save these files?

Ankit Shubham
  • 2,989
  • 2
  • 36
  • 61
  • You simply do not have permission to modify that file as a Linux user. – MaxZoom Mar 08 '17 at 22:04
  • As a warning: If you are running a graphical interface and need Geany to code your PHP files running in root context, you should consider stepping one step back and rethink what you are doing. This sounds like bad practice in every, single part. – frlan Mar 09 '17 at 19:27
  • @frlan can you develop? Oh... you wrote that neary 4 years ago. – Arnaud Nov 28 '20 at 21:41
  • @Amaud What do you expect me here to say? I still think this is most likely a very bad idea -- In case you really need to do it, the accepted answers seem to be ok for me. – frlan Dec 04 '20 at 16:02

4 Answers4

7

try

gksudo geany

Use gksudo with graphical apps written in GTK+ instead of sudo

Shady Atef
  • 2,121
  • 1
  • 22
  • 40
  • In Ubuntu 20.04 gksudo is not installed by default. Is it OK to install it or will it break my system? – Arnaud Nov 26 '20 at 17:24
  • gksudo is outdated and not maintained, so it was removed. I believe Ubuntu-based distros now use Policy Kit, so you can check this https://linux.die.net/man/1/pkexec for more information. – Shady Atef Nov 28 '20 at 11:24
1

sudo -Eb geany

worked for me on Debian 10 with xrdp. I executed the command on xrdp desktop Terminal Emulator.

-E: preserve user environment when running command
-b: run command in the background

Note that without -b option the control will not return to terminal until geany is closed.

Not an expert on this, was just trying to see sudo's options and this did the trick!

Uttam
  • 596
  • 1
  • 6
  • 11
0
sudo geany

but you really shouldn't edit your code in production environment

cymruu
  • 2,808
  • 2
  • 11
  • 23
  • That gave me this error :(geany:25318): Gtk-WARNING **: Unable to locate theme engine in module_path: "pixmap", (geany:25318): Geany-WARNING **: Geany tried to access the Unix Domain socket of another instance running as another user. This is a fatal error and Geany will now quit. – Ankit Shubham Mar 08 '17 at 22:09
  • try `gksudo` instead of `sudo` – Shady Atef Mar 08 '17 at 22:18
  • @Shady Atef Yeah! That works! Maybe you should add this as an answer :) – Ankit Shubham Mar 08 '17 at 22:22
0

if you are developing locally navigate to your www file using terminal after that you have to change the permission to 777 using this command sudo chmod 777 html which mean every one can read-write-execute your files REMEMBER THIS IS FOR LOCALLY DEVELOPING

mohammed
  • 26
  • 1
  • 9