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 have a Java application in which I need to "reveal" a file to the user (i.e. open the containing folder of the file in an explorer and highlight the file). I have configured it to do so in both Windows and Mac OSX, but I have not been able to find a terminal command to do so on Linux/Ubuntu operating systems.

The below batch/terminal commands are the Windows and Mac equivalents of what I am looking for.


Explorer /select,filename


open -R filename
share|improve this question
up vote 1 down vote accepted

The file manager in Ubuntu is called Nautilus, and it seems to do what you are after when you pass a file to it on the command line. For instance, the following command:

nautilus ~/Documents/foo.txt

opens a file manager window showing the ~/Documents folder with foo.txt selected.

share|improve this answer
Thanks! I have one question though: when I posted a related question on StackOverflow, I received a response which said "On Linux it would depend on the window manager or file browser they are using." Would that command you posted work on most Ubuntu/Linux systems? – Vulcan May 8 '12 at 18:57
It should work for people using the Unity or GNOME desktops (Nautilus is the Gnome file manager). You would need something different for Kubuntu or Xubuntu desktops. There are cross-desktop tools like xdg-open that should open the desktop's file manager if you pass them a folder, but this doesn't give you a way to select a file in the folder. If I used xdg-open in the example from my answer, it would instead open a text editor. – James Henstridge May 9 '12 at 0:33
Although xdg-open doesn't reveal the file, I'll use that for Linux users so that functionality is ensured. Thanks again. – Vulcan May 9 '12 at 2:52

Your Answer


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

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