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.

This question already has an answer here:

I could not find the section as you can open the file in a graphics mode, that is such a file 1.txt terminal displays the contents but I would love to see it with the gedit or another text editor?

share|improve this question

marked as duplicate by Eric Carvalho, Mitch Aug 3 at 8:59

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
How do you open a file in the terminal? –  Braiam Jul 26 at 13:46
    
simply gnome-text-editor "<filename>" –  Pandya Jul 26 at 13:52
2  
Unclear/misunderstanding that if you want to open file in terminal or launching gui app by command-line? –  Pandya Jul 26 at 13:55

3 Answers 3

up vote 3 down vote accepted

You can do that by entering the program name before the file name.

So to open index.html with gedit from a terminal you would use :

gedit index.html

It should be noted that this will run from the terminal, if you want to separate it and continue using the terminal simply add an & after the command, for example :

gedit index.html &
share|improve this answer

You would just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:

<program_name>
or
sudo <program_name>

To open a .txt file using gedit from terminal, you would do

gedit <file_name>

Note: Make sure that the program that you're trying to open is in your path; otherwise you have to enter the complete path.

share|improve this answer

Opening a text file in a text editor is as simple as Fernhill Linux Project's answer.

For a more generic "open with default program" command you may type xdg-open filename.

A video file would open with your default video player, a text file with your default text editor, etc.

This has the added advantage that you may close the terminal window without closing the application.

share|improve this answer

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