Opening the file browser from terminal

  • 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.

  • mgunes

    mgunes Correct answer

    10 years ago

    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

    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.

    It shouldn't have root permissions unless you launch it with `gksudo`.

    simply you can type nautilus in command text. I have done the same shorcut using Win+E for opening nautilus

    this seems to work OK, but throws a ton of errors for me and others.

  • 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


    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 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.

    To update this answer: gnome-open is now called gvfs-open. If you want a desktop-agnostic command, you can also use xdg-open.

    This leaves the terminal hanging awaiting more input, so you have to kill with Ctrl-C

    @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.

    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`

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

    gio open some/directory

    Excellent, works great in 18.04, thanks!

  • 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.

    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.

    Works like a charm :)

    For me, this option also hangs the command line... (Ubuntu 18.04)

  • I put the following line in my .bashrc:

    alias opn="nautilus -s ."

    Now you can open with

    $ opn /path/to/folder

    There is a command named `open` already in package `kbd`, it's linked to `openvt`.

    Working in Ubuntu 18.04 too, unlike some of the other answers here.

    cool answer. it helps to create the shortcut.

  • You can use

    • nautilus PATH for the Gnome
    • nemo PATH for the Cinnamon
    • caja PATH for the MATE
    • thunar PATH for the Xfce
  • 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.


    browse . Opens the file explorer in my current directory.

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

    xdg-open 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.

  • Use nautilus

    For root file browsing, it's gksudo nautilus.

    1. Using nautilus for current directory -> nautilus ./
    2. Using gnome-open for current directory -> gnome-open ./
      For gnome-open if might be required to install sudo apt install libgnome2-bin

License under CC-BY-SA with attribution

Content dated before 6/26/2020 9:53 AM