Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

When I need to edit a file (e.g. the httpd.conf file or the php.ini file) I start a terminal and open it with:

sudo vim /etc/apache2/httpd.conf

Most of the times, in order to be able to edit the files that I need without having to sudo all the time, I do a:

sudo bash

and stop worrying about sudo. However, in some cases, I prefer to edit files with gEdit or some other text editors. Most of the times though, the user that I'm logged in as, does not have the necessary permissions to edit the specific file. So my question is the following:

Besides opening gedit through Terminal with sudo, is there any easier way to edit a text file as Super User so that I don't get access denied errors? The same question applies to running applications as Super User (e.g. WireShark requires Super User permissions and I have to launch it from the terminal every time with sudo).

Maybe I'm missing something obvious here, but please enlighten me.

share|improve this question
    
I'm not sure how you hope to make it easier. "sudo -i" would save a few characters over "sudo bash". If you have set your $VISUAL or $EDITOR environment variables, you could use "sudoedit foo.bar" to edit foo.bar, which may be easier to remember. But file permissions are the fundamental security mechanism in *nix systems, and reducing the permissions required to alter key files would open up considerable risk of accidental or malicious harm to your system. In particular, exposing a Web server to attack would be dangerous, even unethical, as your Web server could be used to attack others. –  bgvaughan May 22 '11 at 16:30
1  
What I mean by easier, is graphically select that I want to open this file with gEdit as an administrator. Even if I had to right click and select an option like: "Edit as an administrator" it would be an OK solution for me. Because sometimes I go to a directory visually and then have to go there again through the console in order to edit a file. It's a hassle. –  F1234k May 22 '11 at 16:33
    
@Marco Ceppi's response sounds like it may be the right answer. –  bgvaughan May 22 '11 at 16:39
1  
to the second comment here (navigate to a directory visually/with nautilus), then su edit a file: there's a package called nautilus-open-terminal which enables you to open a terminal in the directory you're in. then you just have to gksu gedit <file>, probably the easiest workflow, no navigating in the terminal involved. –  Christoph May 22 '11 at 17:15
add comment

1 Answer

up vote 3 down vote accepted

You don't need to drop into root everytime you want to run a few applications. You can add new menu items to your system which will launch applications as the root user (via sudo and gksudo) Adding new menu items is outlined in How can I add and change items in my Applications Menu? Just look up the software's command in alacarte, copy it for the new entry and prior to it's command add gksudo IE: gksudo gedit

Typically I make a new folder called "System Tools" and place those under there.

Once you create the entry in alacarte you can then Right Click the file, Open With another Application, and choose the new entry you've create in alacarte as the software to open with.

share|improve this answer
add comment

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.