Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to open a file using the terminal on ubuntu.

To have it independent from the terminal, I use gnome-open:

gnome-open text.pdf

And since I'm lazy, I also have this alias in my .bashrc:

alias g='gnome-open'

So when I type g text.pdf the file opens in evince but here is my problem:

The terminal is still open! I often don't need the terminal at that moment and since I'm using a tiling window manager it's wasting space so I close it manually which is annoying.

Is there a way to automatically close the terminal after the file was opened?

share|improve this question
up vote 1 down vote accepted

Maybe I'm not understanding the question but I would use something like [program] [file-to-be-opened] & exit. So, if I have a file called something.txt and I wanted to open it from a terminal with a GUI-based text editor, Leafpad, and close the terminal, I'd open a terminal and run:

leafpad something.txt & exit

where exit is used to close the terminal.

share|improve this answer
Thank you for your answer! This is the command I was looking for. It's not very handy to use since it's a lot of typing but I could build a function for my .bashrc: function g {gnome-open $1 & exit} – user145038 Mar 28 '13 at 16:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.