2

I switched to Ubuntu so that I could run my webserver on HHVM rather than WAMP. But I'm encountering basic problems that are slowing down my development time significantly. I feel this is probably a simple issue to address, but every post on the internet is "here's how you do this in terminal, and here's why it's the most dangerous thing in the world."

What I'm looking for is pretty simple: I want to load sublime (or gedit, or text editor of choice) and edit files in the /var/www directory WITHOUT having to change the owner, group, or permissions of the /var/www directory. I DON'T want to load my text editor through terminal - I just want to click on the side bar, choose a file, and it works.

I realize that as developers, yes, we can jump through hoops to resolve these problems on an individual basis through the terminal. But I just want to load up the desktop and enter the project without having to worry about loading several new commands when I need to change a virtual directory in /etc/nginx or something.

How can I have a one-click solution to the "privileges denied" issues when trying to locally edit system files / files that are protected for a reason? Bearing in mind I ONLY want to do this locally, thus not wanting to change their protective settings.

Edit: This question is 95% resolved. It would be preferable if Ubuntu Desktop version were slightly more accessible for development purposes for superusers, but the accepted answer by Jacob addresses the main issue and showcases some interesting functionality with Ubuntu.

5
  • 1
    without terminal, but would you find it acceptable to enter the administrator's password (gui way)? May 10, 2014 at 17:48
  • Doing it with admin password wouldn't be the optimal solution, but it would be a better solution than what I'm doing right now.
    – user280209
    May 10, 2014 at 18:00
  • OK, I'll add a description in my answer, in a few minutes. May 10, 2014 at 18:06
  • 1
    Why don't you want to change the permissions of the /var/www directory? Seems a really easy way to solve the problem. It's the least "jumping through hoops" way I can think of
    – user1477
    May 10, 2014 at 18:20
  • For wordpress development on a vm i add my user to the www-data group then i changed the permissions of folder and files that i want to access often to 775(folder) and 664(files). After that i can access and edit without problems and root access. If this is an option for you i can descripe it more detailed in an answer.
    – TuKsn
    May 10, 2014 at 19:36

1 Answer 1

2

You could simply make the files accesible via the Unity launcher, adding a link to an icon in the Unity launcher, automatically entering the password via a script. I would however prefer the solution below.

I think the best solution to quickly access and edit password-protected files would be to add (lock) gedit (or any editor of your choice) to the launcher and edit its desktop file, adding a few entries, accesible by right-clicking.

To enter the password you need to install gksu first, then:

  • Copy the default gedit.desktop file to your local directory:

    cp /usr/share/applications/gedit.desktop ~/.local/share/applications/gedit.desktop
    
  • Open the file with gedit (open gedit, go to ~/.local/share/applications, drop the file on to the gedit window)

  • Paste the following at the end of the file (in this example to open fstab file):

    [Desktop Action fstab]
    Name=edit fstab
    Exec=gksu gedit /etc/fstab
    OnlyShowIn=Unity;
    
  • Then look for the line starting with Actions=, add the name of your new mention (in this example fstab) + ;, so the complete line should look something like Actions=Window;Document;fstab;

After log out and back in, your files are accesible, you only have to enter the password.

enter image description here enter image description here

4
  • Awesome, this mostly worked. I had to change the original file (the local version didn't seem to work), but I was able to set the instruction for Exec=gksu gedit, which granted general rights to everything. Nifty feature there.
    – user280209
    May 10, 2014 at 19:02
  • @user280209 The local one should work after log out/in, did you do that? (It will overrule the global one anyway if it is still there :)). Nice to hear it worked out. May 10, 2014 at 19:04
  • Yeah, I tried logging in and out a few times (and restarted the computer), but it didn't accept changes until I edited the global file. shrug
    – user280209
    May 10, 2014 at 19:07
  • @user280209 That is odd... could it be something went wrong editing? Anyway, great it it works. May 10, 2014 at 19:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .