0

I have the latest version of Ubuntu installed on my computer. I would like to set it up so that I can comfortably program in PHP, JavaScript, HTML and CSS.

So I've installed Nginx and set it up, MySQL and set it up, I have an editor in place (Haven't decided between Sublime Text 2 or PhpStorm 6, but that's outside the question at the moment), and it kinda works.

My main problem is that I need to sudo anything in order to be able to edit or even access any of the configuration files, or even the public www files. That's annoying as hell. I don't want to keep Terminal windows open for every program I need in order to develop. I know that there's gksu but again, it's annoying to have to identify for everything again and again.

Also, I can't install sublime-text plugins because of permission denied errors. Again, I don't want to sudo every time I use sublime!

It's worth mentioning I'm developing in GUI, including running programs and whatnot.

Thanks in advance.

Madara's Ghost
  • 607
  • 4
  • 9
  • 23

1 Answers1

0

To be able to change any file from the file manager, use:

sudo nautilus

To run it in the background use:

sudo nautilus &

To change the files so you always have access to them, right-click on each folder and click Properties then the Permissions tab and then change the permissions in the dropdown to your username instead of root. Make sure you can read and write to the directory. This isn't safe for most configuration files.

To be able to change only the thing you're working on, you should always launch a terminal for that user that can change just the things you need. That's what makes Linux safe. Esspecialy for a server (wwww). Then launch the GUI's from that user. (Like nautilus or the text editor). To be able to change the files in the www folder use:

sudo su - www-data -s /bin/bash (opens a new bash shell inside the shell with the www-data user)

From here you can do things like:

gedit &(this launches the gedit text editor in the background with which you can edit all file in the www folder. You can use any other editor. After this you can close the terminal if you don't want the debug info.)

If you made new files in the www folder with root, these files will have root as user and group, you should change these to www-data.

www-data could also be www or some other user.

The best way is still to copy, edit with normal user, backup and copy back with privillaged user and change permissions. But I can see why you'd not want to do that every time.

labsin
  • 565
Ads20000
  • 1,963
  • When I try that, for some reason Nautilus crashes. It tells me the specified owner (Madara Uchiha) doesn't exist, then crashes and ask me to send an error report. What's wrong there? – Madara's Ghost May 31 '13 at 09:34
  • @MadaraUchiha No that shouldn't happen. – labsin May 31 '13 at 10:53
  • I installed Ubuntu to ease up my development process, I wanted a faster system, where I can quickly develop and test instantly, without the distractions that come with Windows. But so far, Windows is much better at this. Everything just works*, and little-to-no setup is required. Here, even after the extensive setup, the environment is still* not "perfect", I still have all these quirks. Is it possible for me to simply open sublime text, edit files, and see the result in the browser? Without any fancy process I need to do each time? – Madara's Ghost May 31 '13 at 11:36
  • @MadaraUchiha: Yes, then you have to change the user of your http-server to your user and then do sudo chown -R name:name www-folder. That way, you can write php scripts that can change your files and you can change them yourself. The reason for this all is that the windows packages you speak of are FAR from the security you get with linux. The default in Linux is Secure. If you want to go to insecure, you'd have to come up with it yourself. These packages do just work. You get a good dedicated secure server with a couple of commands. – labsin May 31 '13 at 13:23
  • Having to use a terminal just to open a GUI application feels wrong to me. – Kwebble Jul 27 '16 at 12:37
  • Yeah, but that's how it's done (I suppose people shouldn't be messing with root Files if they don't know what they're doing, so the Terminal is a useful hurdle).

    Also, I've read that it better to use pkexec nautilus to open graphical applications as root, otherwise things might get messed up, but this doesn't work for Files yet (it might work in Files 3.22 which should be released in Ubuntu 17.04).

    – Ads20000 Sep 19 '16 at 09:16