96

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?

Jorge Castro
  • 73,717
zharvey
  • 1,795

6 Answers6

126

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
Fabby
  • 35,017
Roman Raguet
  • 9,613
20

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.

Julien B.
  • 311
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.

wsaleem
  • 333
15

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

2

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!

Kulfy
  • 18,154
Rob
  • 111