89

I was wondering if anybody knew a command that would allow me to open a Nautilus (if that's the right name for the Ubuntu graphic/window explorer) window from the command line at the current directory that the user is at.

So, if I open a command line, and type:

cd /home/myUser/some/long/path/to/a/directory

Then, I'd like to be able to issue some command:

nautilus open-sesame

And have a graphic window opened to /home/myUser/some/long/path/to/a/directory. Is this even possible?

120

You can type in the terminal:

cd /home/myUser/some/long/path/to/a/directory

and then:

nautilus .

The above command will open nautilus in the folder /home/myUser/some/long/path/to/a/directory (the period is the current directory)

Or in the Terminal just type:

nautilus /home/myUser/some/long/path/to/a/directory
3
  • 1
    won't work in ubuntu 16.04 Aug 16 '17 at 18:31
  • 1
    @KasunSiyambalapitiya It does work on my Ubuntu 16.04.3 LTS with a fresh install and nothing special installed. Feb 25 '18 at 18:00
  • 1
    alias open="nautilus", and you can using $ open <PATH_HERE> like the MacOS.
    – Marslo
    May 10 '18 at 8:30
16

You can also do gnome-open .. gnome-open is similar to open on Mac which tries to open the file using the best matching application. By default, gnome-open . on Ubuntu will open the current directory in Nautilus.

There is an open command in Ubuntu as well but it does not work in this case.

2
  • 5
    In Ubuntu 16.04 it isn't installed by default: "The program 'gnome-open' is currently not installed. You can install it by typing: sudo apt install libgnome2-bin" Feb 25 '18 at 17:59
  • @WinEunuuchs2Unix: calling gnome-open directly is deprecated (it already was in 2014). Use the generic xdg-open instead.
    – MestreLion
    Sep 13 '20 at 15:04
13

In order to avoid nasty warnings in my terminal I use nohup. To have it detached from my terminal I'm adding & at the end of my command. I also use the -w flag to open in a new window.

nohup nautilus -w . &

Note that, nohup will create a file with warnings.

You can send that to /dev/null like this:

nohup nautilus -w . > /dev/null &

EDIT:

If you don't want to type all of this all everytime you want to open nautilus, you can make a function and place it in your .bashrc or into a file that is sourced when you open your console.

open() {
    nohup nautilus -w $1 > /dev/null 2>&1 &
}

You could then use :

$ open path/to/open/

I would prefer that over an alias as mentioned here since it allows you to specify the path to open in nautilus.

1
  • Smooth command! I was just trying to open Nautilus from terminal and detach it from the parent process (i.e., the terminal), but I was unsuccessful (I tried nohup and &) your combination nohup nautilus -w . & works perfect. Aug 9 at 15:38
8

You should use xdg-open . (or xdg-open <path>) which is way more generic.

0
1

To open nautilus from terminal.

nautilus .

To open nautilus in the background and still use the terminal.

nohup nautilus . > /dev/null 2>&1 &

You can also make that an alias.

alias open='nohup nautilus . > /dev/null 2>&1 &'

You can also add that alias to .bash_aliases, to have it persistent.

echo "alias open='nohup nautilus . > /dev/null 2>&1 &'" >> .bash_aliases

So now, after restarting the terminal, you can just type open.

1

I'm running Ubuntu 18.04.4 LTS and I also experienced problems with some of the popular solutions above. What is currently working for me is:

nautilus -w $(pwd)

This method does not require additional installs, creating files, error handling, etc, and so appears to be the simplest.

I hope it helps!

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.