20

TL;DR: when posting a solution could you please standardize any editors to something that firstly comes with vanilla Ubuntu, and secondly, is simple to use, regardless of your personal preferences.

I just installed Ubuntu 17.04 for my daughter. It couldn't connect to wifi during installation, so had to install via Ethernet, and after installation during troubleshooting I found this question, which turns out is an easy fix.

Problem was, they chose gksu gedit to edit the file,which is no longer native to vanilla Ubuntu, with other problems involved for 64-bit OS

A seasoned user may automatically replace gksu gedit with sudo vi without any thought,but I'm not one. I tried vi,gedit,etc; then had to google how to close vi. Laugh all you like. On the other hand, I approve of gedit as a suitably Windows user-level editor, but if it can't be elevated using sudo, it's no good either.

9
  • 1
    So, what is the problem with sudo nano?
    – Bruni
    Commented Jul 21, 2017 at 11:16
  • 7
    You can use Gedit as root. Just do sudo -H gedit. Commented Jul 21, 2017 at 11:39
  • Well gedit gives some warning message in the terminal when it closes, that's apparently safe to ignore, but again, sheeple, less messages is better. In any case, cool, thanks. Like, upvote, mark as answer, etc
    – Cuchul
    Commented Jul 21, 2017 at 13:33
  • 2
    I agree that nano would be the best choice for a terminal editor Commented Jul 21, 2017 at 15:33
  • 12
    Calling people sheeple... blegh.
    – ave
    Commented Jul 21, 2017 at 16:22
  • 2
    Even most seasoned C programmers have moved from text-based editors to GUI editors to maintain their source code . As such it makes sense there are other users like me who prefer gedit for editing configuration files rather than vi or nano. After learning Ctrl+i to jump to a line number in gedit why do I want to relearn that in a text based editor? Commented Jul 22, 2017 at 17:30
  • Who uses vi? vim is the solution. ;)
    – user364819
    Commented Jul 23, 2017 at 10:48
  • 9
    I think the point is we really need to stop people recommending users to open vi or vim. There is nothing to laugh about one having to Google how to exit them, because it's a weird mess. This has been already debated in a question. Commented Jul 23, 2017 at 12:34
  • 3
    Wait... You can exit vi???
    – wjandrea
    Commented Aug 1, 2017 at 1:39

2 Answers 2

20

We should absolutely not be recommending the use of gedit as root (through gksu or worse, sudo) to any user, professional or otherwise. See my answer here for reasoning, as well as a similar thread regarding the "dropping" of gksudo.

Anything that requires the use of root is probably something that requires caution to be exercised. Therefore, it would be appropriate to add friction to the process. I would hope that new (and therefore inexperienced) users would be far more cautious when they're in the "spooky scary command line," mostly because it is scary. One wrong move causes an entire system to break in potentially fascinating ways.

To that regard, nano is basically the friendliest text editor on the command line, and is more or less perfect for this sort of operation. After users get their feet wet and start to understand what's going on, they'll start reading sudo nano /path/to/file as "open /path/to/file as root in a terminal" and they'll choose their own editor appropriately.

While sudoedit/sudo -e is a good tool, it's also giving the user a complicated choice of "what do any of these things mean, and what should I choose?" which would also add unnecessary overhead in questions that may not apply in all cases ("choose 1 to use this editor" - after first-run, this isn't a choice).

In my opinion, it's best to just use sudo nano, user-experience be (intentionally) damned. Once the user has more knowledge of how Ubuntu works, they'll be comfortable enough to know that nano really means "insert your favorite editor here."

4
  • 7
    While I agree that users should exercise caution in command-line, this is exactly the type of things that I dislike. Command-line isn't scary, it's just text. Windows has spoiled generations of users with GUI where it's a lot easier to make mistake by misclicking, while the basic text console, where you use buttons, not mouse, is perceived as scary. Commented Jul 21, 2017 at 17:45
  • 1
    The CLI equivalent of misclicking in GUI would be adding extra spaces by accident and deleting /. Anyway, I agree with the sudo nano approach; it is a reasonable middle ground.
    – edwinksl
    Commented Jul 21, 2017 at 20:12
  • "One wrong move causes an entire system to break in potentially fascinating ways." Spoken like a true scientist. +1 Commented Jul 26, 2017 at 22:24
  • @kaz "Therefore, it would be appropriate to add friction to the process". I strongly disagree with this perspective. If you're not managing a server (which many users of askubuntu are not), most of your important stuff is your user files, which aren't protected anyway. Frankly, if i were to accidentally run rm -rf ~ it would be way worse than rm -rf / --no-preserve root since the second one would allow me to cancel it while destroying less stuff relevant to me.
    – k_g
    Commented Jul 27, 2017 at 0:01
8

sudoedit should be the preferred choice for command-line editors if you want to remain agnostic. That lets the user choose on first-run.

The problem with this approach is it forces the user into a terminal. Many new users are deeply uncomfortable with something they perceive an archaic 80s technology. That's why so many of the answers suggest ramping gedit (which does ship with standard Ubuntu) up to root.

And gksu gedit works here.

$ dpkg -S $(which gksu)
gksu: /usr/bin/gksu

$ cat /etc/lsb-release 
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=17.04
DISTRIB_CODENAME=zesty
DISTRIB_DESCRIPTION="Ubuntu 17.04"

$ apt policy gksu
gksu:
  Installed: 2.0.2-9ubuntu1
  Candidate: 2.0.2-9ubuntu1
  Version table:
 *** 2.0.2-9ubuntu1 500
        500 http://gb.archive.ubuntu.com/ubuntu zesty/universe amd64 Packages
        100 /var/lib/dpkg/status
8
  • 1
    Hi, Oli, is there any problem with using sudo -i gedit?
    – pa4080
    Commented Jul 21, 2017 at 11:38
  • 4
    @pa4080 use sudo -H gedit. Commented Jul 21, 2017 at 11:39
  • Thanks @TheWanderer ! I understand that via -H option some user files will be written in /root directory, but when -i is used these files will not be written - or they will be written into the current user's home directory?
    – pa4080
    Commented Jul 21, 2017 at 11:47
  • 5
    @pa4080 -H resets $HOME, -i resets more than that. -H is safe, -i is safer. Those files should be written in /root, otherwise they'd be written in your home directory and you'll end up with a bunch of root-owned files and directories in your home directory that can cause problems later.
    – muru
    Commented Jul 21, 2017 at 11:58
  • Wait what? When did gedit stop getting bundled with Ubuntu??? Commented Jul 21, 2017 at 15:28
  • 4
    @AndroidDev gedit still comes with Ubuntu (though not with all official Ubuntu derivatives). It is gksu/gksudo that is apparently not in the default installation of some releases. Commented Jul 21, 2017 at 16:27
  • gksu was not installed by default in my installation. I'm using the default Ubuntu version (i.e. not using any derivatives), I'm also using 17.04 (fresh installation was on 15.10). Any chance you may have installed gksu manually, or maybe you have it installed from an older version of Ubuntu?
    – Dan
    Commented Jul 24, 2017 at 8:40
  • "gedit still comes with Ubuntu (though not with all official Ubuntu derivatives). It is gksu/gksudo that is apparently not in the default installation of some releases" All the more reason, in my opinion, to use sudo nano.
    – chili555
    Commented Jul 30, 2017 at 1:54

You must log in to answer this question.

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