What are the default text editors (GUI and CLI) in different flavors of Ubuntu. what commands should we use to edit files with them?
Behind the question
I tried Kubuntu and want to try more Ubuntu flavors and other distros, but when I was in Kubuntu I tried so hard to run gksu gedit /path/file.txt
which wont work because gedit isn't the default text editor in Kubuntu, it's kate. I'm glad nano
was available. but if I want to try more flavors I must know what are the default text editors in various Ubuntu flavors
I think Answers by Muzaffar and Terrance serves your need. One thing to note is that you can install any of these text editors in any flavors.
GUI Text Editors
Gedit
Default in:
Gedit is certainly the most famous text editor in the Ubuntu world. Gedit is also available for Windows and MacOS. To install Gedit on any Ubuntu flavor use the following command:
To open a file with gedit:
Kate
Default in:
it is also available for Windows. Like many KDE apps it has a load of features. To install, run:
If you want the latest version of Kate, you'll need to add a PPA:
To open a file with kate:
Leafpad
Unlike Kate, emphasis of Leafpad is on simplicity and lightness, which is whole agenda of the LXDE project. It comes pre-installed on Lubuntu. To install:
To open a file with leafpad:
Mousepad
Default in:
In philosophy, Mousepad is pretty similar to Leafpad. To install:
To open a file with mousepad:
Pluma
Pluma is a fork of Gedit which comes preinstalled in Ubuntu Mate. To install:
To open a file with pluma:
*Note: if you want to edit files with root privileges, add
gksu
in front of a command, like this:It's best to avoid using it with kate
CLI Text Editors
Nano
I don't know if Nano is installed on all the Ubuntu flavors, but it's installed on Ubuntu Unity, Ubuntu Gnome and Kubuntu as per my knowledge. To open a file with nano use following command:
For more information about Nano, see The Beginner’s Guide to Nano, the Linux Command-Line Text Editor.
Vim
To open a file with Vim, type either of these two commands:
or
Vim (or at least vi) is installed by default on all Ubuntu (or any other Linux) flavor. If you start to like Vim and want it to have a user interface try Gvim. Also note that on some systems,
vi
is aliased tovim
, so both commands do identical things. (which launching vim)For more knowledge about vim, see A Beginner's Guide to Vim or run
vimtutor
in the terminal.Keep in mind that QT apps don't look good on Gtk based desktop and vice versa. but if you want them to feel at home, try this question How to make KDE applications look native in GNOME?
More Linux Text Editors
Flavors of Ubuntu can change all the time and so can the default GUI editors. Instead of trying to remember all the default GUI editors of each distro, as long as the
xdg-utils
are installed you can run a simple command ofxdg-open
so you know what the default editor is and can launch it editing a text file:xdg-open
can also launch what the default audio player is when you open a .MP3 file. Or if you want to quickly open a webpage you can usexdg-open www.somewebsite.com
and it will launch your default web browser.For the command line,
vi/vim
&nano
seem to be the most common across Ubuntu flavors as being the default installed editors.vi/vim
should be in all flavors of Linux.You can change the default command line editor with the following command then you can choose which one you want as your default:
For
sudo
orroot
:For your login:
Example:
Then since the command
/usr/bin/editor
should be in your path, to edit a file you can just run the following to edit your file:Or if you need elevated:
Hope this helps!
Kubuntu - kate
Lubuntu - leafpad
Xubuntu - mousepad
Ubuntu Gnome - gedit
Ubuntu MATE - pluma
Ubuntu Budgie -gedit
Ubuntu Kylin - gedit
Ubuntu Studio - mousepad
Neither
nor
is foolproof, unless you DEFINE "default" as whatever they invoke, which is not the sense in which it is commonly used.
For example, on my xenial systems:
I don't have a global EDITOR variable defined:
So
$EDITOR some_file
fails completely in either a gui environment (x & openbox, in lxterminal), or in a tty.In a gui environment
xdg-open some_file
opens the file in vi. In a plain tty, it ATTEMPTS to do the same, but fails. But vi is not my "default" editor in the sense the word is most commonly used. All the file managers I have installed agree that my default editor ised
(no, not THATed
- if I were that masochistic I'd usevi
, myed
is a script I wrote).There may be a justification for defining "default" in terms of one or the other of those commands, but in the general usage of the great majority of users, "default" is an adjective applied to whatever program opens a file when you double or single click on it in a gui file browser (like Nautilus, Pcmanfm, Thunar, etc.), (double or single depending on the settings in that PARTICULAR file browser). Or, alternately, whatever program opens the file when you highlight it and press enter in an orthodox file browser like Midnight Commander.
So, in the most common usage of "default", you can have a different default for each file browser, and when you speak of default without qualification it means whatever is the default in the default file browser. And the default file browser in a graphical environment would be the one that opens if you double click on a directory (aka "folder") or a symlink to a directory on the desktop, or if you don't use the desktop metaphor, maybe the one most featured in a menu. As far as I know, in this sense, which is the normal real world usage, Sumeet Deshmukh's answer is totally correct and totally complete. It may be in the more abstract senses as well.
In a non-graphical environment, outside of an orthodox file manager, the common sense of the word "default", applied to an editor, has no normal application. Nobody working in tty invokes an editor with
xdg-open some_file
or$EDITOR some_file
unless they are working on somebody else's machine, don't want to install anything, and have gotten desperate. They open an editor by directly invoking the one they want to open, BY NAME. If they getbash: gedit: command not found
they try their second favorite, etc. What the default is, is irrelevant. All that matters is their preferences and what's installed or can be installed.The Main Point:
Wrong. And that's why I posted, to explain why that statement is wrong and why that command failed. What the default editor is, however you define it, is irrelevant.
For that command to work, you need 2 things:
Both programs,
gksu
andgedit
, must be installed on the system.You must have suitable permissions for the file and it's ancestral directories. You have to have x on all directories in the path, at least r on the file itself, and probably at least r on the parent directory. Some editors might require w on the file or even on the parent directory, although they shouldn't.
You should be able to tell why the command failed by reading the error message. If you like gedit, install it.
But gksu is dangerous. Use gksudo if you need it. But don't use any of the su/sudo/gksu/gksudo/pkexec type commands unless the command that follows fails without it. And even then, only if it SHOULD have failed. If it should have worked, using some sudo-ish command to MAKE it work is like "If it don't fit, get a bigger hammer". It will create more problems down the road. In that case, correct the permissions , and try to figure why they were wrong in the first place.
Nor are any of the sudo type commands omnipotent. Sometimes, you MUST change permissions before you can edit the file even WITH gksudo.
Regarding the dangers of
gksu
listen to Paddy who commented on Sumeet's answer. He is wise chap who has been around a while. Repeating his 3 links: