73

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?

103

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
  • 1
    won't work in ubuntu 16.04 – Kasun Siyambalapitiya 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. – WinEunuuchs2Unix 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
14

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.

  • 4
    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" – WinEunuuchs2Unix Feb 25 '18 at 17:59
3

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

3

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

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.

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.