192

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.

Jon Doe
  • 11,777

12 Answers12

191

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
mgunes
  • 9,910
64

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.

rsenna
  • 1,495
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.

Eliah Kagan
  • 119,640
41

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.

R J
  • 624
15

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.

Tyrel Kostyk
  • 261
  • 2
  • 3
13

I put the following line in my .bashrc:

alias opn="nautilus -s ."

Now you can open with

$ opn /path/to/folder
abu_bua
  • 11,313
pindabaas
  • 149
6

On ubuntu 20.04 run: browse ./directory_path

Armin
  • 161
4

You can use

  • nautilus PATH for the Gnome
  • nemo PATH for the Cinnamon
  • caja PATH for the MATE
  • thunar PATH for the Xfce
1t1e1
  • 149
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 .
thanos.a
  • 171
  • 4
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
Aks
  • 649
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

lacostenycoder
  • 538
  • 1
  • 6
  • 15
0

Use nautilus

For root file browsing, it's gksudo nautilus.

8128
  • 28,868
Lyrositor
  • 1,018