Suppuse I have some text file and I want to open it with text editor, how to do that from terminal?.

  1. I need it that it would work for Red hat 5.3 enterprise.
  2. Without need to download nothing, I need the built in text editor.

I need something like: [root@localhost]# open /home/Plompy/Desktop/README_PLOMPY

That equivalent to this:

enter image description here

  • 1
    Hi @Plompy.. Just type in terminal gedit /home/Plompy/Desktop.README_PLOMPY is this what you are looking for?
    – user88036
    Sep 21, 2018 at 14:22
  • @Goro I am trying to edit Plompy.h file, I tried gedit now but it tells: No protocol specified and Unable to init server: Could not connect: Connection refused and (gedit:12764): Gtk-WARNING **: 20:24:45.829: cannot open display: :0, While I succeed to open it manually from text editor
    – Plompy
    Sep 21, 2018 at 14:29
  • Are you open it on a server? try sudo gedit /home/Plompy/Desktop.README_PLOMPY or sudo nano /home/Plompy/Desktop.README_PLOMPY
    – user88036
    Sep 21, 2018 at 14:31
  • @Goro I installed ftp server, but I'm running Fedora right now
    – Plompy
    Sep 21, 2018 at 14:31
  • 1
    gedit is the official text editor of the GNOME desktop environment. Generally, in a server, there is no desktop environment installed or needed. Therefore, gedit can't start and display. I would suggest sudo nano /home/Plompy/Desktop.README_PLOMPY instead
    – user88036
    Sep 21, 2018 at 14:32

2 Answers 2


In Ubuntu exist a command called xdg-open, that opens a file or URL in the user's preferred application, so you can open several types of files with the default program pre-defined.

xdg-open hello_word.tiff Open the file using the default image visualizer.

xdg-open Template.odt Open the file using with LibreOffice.

xdg-open myfile.txt Open the file using gedit (Text editor).

By my knowledge the xdg-utils are already installed in Red hat.


For the users who got here by Google search looking for a different answer, who want want to stay in the terminal: check to see if there's a defined editor, then try something else, like nano file, or use xdg-open file as a less portable fallback.

if [ -z ${EDITOR} ];  
    xdg-open myfile.txt; #from Luis's answer above  
    $EDITOR file.txt;  

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.