181

What's the command to open the file browser? I want it so that I can assign a keyboard shortcut to open a specific folder.

1
  • 1
    I add an & after command, whatever it is, so the terminal stays available for new commands. Appending space & after a command runs it in its own environment, dissociating it from the terminal.
    – Juan Lanus
    Sep 14, 2020 at 14:31

13 Answers 13

183

nautilus --browser will ensure that Nautilus is launched in browser mode even if you're normally using it in spatial mode.

You can append the path you want to open to the end:

nautilus --browser ~/some/directory
6
  • But the problem I have with nautilus is that it has root permissions. How can I avoid that? I don't want to accidentally delete any files.
    – Jon Doe
    Oct 21, 2010 at 0:03
  • 5
    It shouldn't have root permissions unless you launch it with gksudo.
    – mgunes
    Oct 21, 2010 at 0:11
  • simply you can type nautilus in command text. I have done the same shorcut using Win+E for opening nautilus
    – Amit Rane
    Mar 28, 2015 at 13:45
  • 1
    this seems to work OK, but throws a ton of errors for me and others. Jul 26, 2016 at 19:26
  • Most of this solutions need a running instance of nautilus, which on most environments is started to show the desktop icons. If not you will get a message like Message recipient disconnected from message bus without replying I had to enable my desktop icons using gsettings set org.gnome.desktop.background show-desktop-icons true
    – gschaden
    Nov 30, 2022 at 14:24
62

The gnome-open command will open a directory with the appropriate application, which in this case is Nautilus:

gnome-open PATH

This will open the directory /tmp using the Nautilus file browser.

gnome-open /tmp

Or:

cd /tmp
gnome-open .

I like the gnome-open command because you can use this exact same command to open a file with the appropriate application. No need to remember any funny flags. It just works.

  • gnome-open file.pdf will open the PDF in a PDF browser.
  • gnome-open file.zip will open a zip file using the Zip archive viewer.

It's also similar in name and function to the Mac OS X open command, for those of us who use Macs.

4
  • 29
    To update this answer: gnome-open is now called gvfs-open. If you want a desktop-agnostic command, you can also use xdg-open. Mar 21, 2015 at 5:12
  • This leaves the terminal hanging awaiting more input, so you have to kill with Ctrl-C Jul 26, 2016 at 19:18
  • 1
    @JeffPuckettII In my experience, gnome-open file.ext will open a file, hand it off to another program and then exit. It does not hang awaiting for more input, at least not on my Ubuntu 14.04 box at home. Jul 27, 2016 at 20:26
  • 11
    To update @JasonChampion's update: gvfs-open is now deprecated, replaced by a small shell script that calls gio open. xdg-open is also a wrapper script, and on most Ubuntu systems it's likely to call gio open. gnome-open still exists as a binary distinct from gio
    – scruss
    Mar 24, 2018 at 13:21
60

As of 2018, one can use the GIO commandline tool on Gnome:

gio open some/directory

Edit: Another option is xdg-open. Also take a look at this answer for further details.

1
  • 1
    gio open . OR sudo nautilus These works. Thanks Sep 6, 2021 at 6:31
38

For me the safest way that is compatible with almost all environments is xdg-open

xdg-open $HOME/test

This would open a directory named test (for example) under your home directory.

3
  • 2
    this is the better answer, compared the accepted answer. The reason is: nautlius opens a folder but it hangs the command line until you closed the opened File Explorer, but this one opens the file explorer and you can still use command line.
    – Franva
    Mar 12, 2020 at 11:19
  • 2
    For me, this option also hangs the command line... (Ubuntu 18.04) Apr 27, 2020 at 8:50
  • 2
    A general rule for all GUI application is: if you don't want them to hang the command line, run them in background, ie. add & at the end of the command. Like: nautilus --browser &
    – raj
    Jan 20, 2021 at 11:31
14

For reference, I'm running Ubuntu Bionic 18.04.

The easiest and safest way I open the file explorer from command line is with the xdg-open command, which itself often aliased as the browse command if that's more your style. xdg-open ships natively with Ubuntu.

xdg-open can also open any file or web URL, and will open it according to your computer's default application for files of that filetype.

Examples:

browse . Opens the file explorer in my current directory.

xdg-open ~ Does the same, but my home directory.

xdg-open https://www.google.ca Launches google's homepage with your default browser (xdg-open will open it as a new tab if a browser session is already open).

Man pages for xdg-open can be found here

Note that the xdg-open command is not meant to be used with root priveleges.

13

I put the following line in my .bashrc:

alias opn="nautilus -s ."

Now you can open with

$ opn /path/to/folder
2
  • There is a command named open already in package kbd, it's linked to openvt. Sep 2, 2014 at 9:53
  • Working in Ubuntu 18.04 too, unlike some of the other answers here.
    – nonbeing
    Jun 30, 2018 at 14:16
5

On ubuntu 20.04 run: browse ./directory_path

4

You can use

  • nautilus PATH for the Gnome
  • nemo PATH for the Cinnamon
  • caja PATH for the MATE
  • thunar PATH for the Xfce
1

Since I am used to explorer . I add an alias to my linux systems.

echo 'alias explorer="gio open"' >> ~/.bashrc

On a new terminal I can:

explorer .
0

Use nautilus

For root file browsing, it's gksudo nautilus.

0

The de facto way in current dabian / *buntu way is now with xdg-open see this answer which is interesting. If you're using bash shell, you may find this script to be helpful especially if you're coming from MacOS using terminal open command.

Here's the bash version

Here's the ported to zsh version

0
  1. Using nautilus for current directory -> nautilus ./
  2. Using gnome-open for current directory -> gnome-open ./
    For gnome-open you might be required to install sudo apt install libgnome2-bin
1
  • Someone voted it down, I can't understand why. We have to type nautilus. at a folder, we want file explorer. nautilus is installed by default with ubuntu 22.04 Jan 19, 2023 at 12:56
-1

You can simply open using a directory in File explorer using

gio open ./ path/to/folder
1
  • This won't open a file browser.
    – Pilot6
    Mar 3, 2023 at 10:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .