51

A while back, I set my default file manager to Nemo. I like it a lot, but it constantly crashes. I remember editing a text file to set it as default, but I forgot which file it was. How do I switch back to the Nautilus file manager?

nick
  • 873

5 Answers5

53

This did it for me, after I google for a while:

xdg-mime default nautilus.desktop inode/directory application/x-gnome-saved-search

I also typed:

gsettings set org.gnome.desktop.background show-desktop-icons true
Anwar
  • 76,649
Damiao
  • 746
  • After that my Linux Mint failed to log in with X-session error g_key_file_free: assertion 'key_file != NULL' failed. To recover use Ctrl-Alt-F1 & sudo apt-get cinnamon and sudo reboot – Zon Jul 18 '18 at 04:26
  • The xdg-mime command worked for me in Ubuntu 16.04. I replaced nautilus.desktop with pcmanfm.desktop since I wanted to use that as my default file manager. You can find the name of the file manager you want to use by using the following command ls /usr/share/applications and finding its corresponding .desktop file. – OwN Jun 19 '19 at 03:08
  • 5/5/20, it works on Ubuntu 19.10 – Anh-Thi DINH May 05 '20 at 07:36
22

I spent AGES trying to find a method that would work. Eventually I found this advice, which is incredibly easy, and worked for me:

Install exo-utils (this package contains the Xfce settings plugin and the utility files for libexo-2-0). Open a terminal and type:

sudo apt install exo-utils

Then run:

exo-preferred-applications

then switch to Utilities tab and select File Manager you prefer.

exo-preferred-applications was dropped entirely in version 4.15.3-1. Install xfce4-settings with sudo apt install xfce4-settings and use this instead:

xfce4-mime-settings
karel
  • 114,770
6

The answers here didn't work for me on Debian Bookworm - so after figuring it out myself:

Premise

Every time I attempt to leverage xdg-open on a directory (typically through an application; like Keybase's "open in file explorer" option, or something similar in Steam), what opens is Visual Studio Code.

What doesnt work

Attempting to "Open with other application" a directory via the context menu in "Files" [Nautilus] (file explorer when using Gnome on Debian) and then "Forget association" on Visual Studio Code (right click on it in the list of applications), subsequently choosing "Files" to open the directory with - does not fix what is used for directories when xdg-open is invoked; it only changes what opens a directory from within "Files" [Nautilus].

What does work

Run the following:

xdg-mime default org.gnome.Nautilus.desktop inode/directory

The standard, as explained, is as follows:

  1. xdg-mime default
    • We're setting a default application
  2. org.gnome.Nautilus.desktop
    • We're setting the default application to be Nautilus, by its fully-qualified desktop menu name; It's registered as org.gnome.Nautilus.desktop.
  3. inode/directory
    • For the mimetype inode/directory (found using xdg-mime query filetype /path/to/target, with target in my case being a directory.)

The accepted answer results in Nautilus.desktop and application/x-gnome-saved-search becoming the default application(s); which is not correct, it must needs be org.gnome.Nautilus.desktop.

Also, setting desktop icons to be shown won't set the default application when opening directories via xdg-open.

Alternatively, you can also set it as follows:

nano ~/.config/mimeapps.list

Scroll down to inode/directory under [Added Associations], as well under [Default Applications], and ensure that the line(s) read:

inode/directory=org.gnome.Nautilus.desktop

You can additionally add, under [Removed Associations]:

inode/directory=code.desktop;

This is just the manual, longer, way of doing what I suggested first - together with the "Forget association" bit I portrayed I had attempted

Restore Behavior in Terminal

A user provided edit surmises that one should source the default list of file associations "for immediate effect". This answer, however, focuses on file associations for when xdg-open is invoked by another application.

With that in mind, and in reviewing the default file associations (on Debian and Ubuntu) at /usr/share/applications/defaults.list;

The default file does not seem to provide the aforementioned association. However, in the event that it did, and/or in the event that you wanted an immediate reflection of the default file associations in terminal (i.e. you're xdg-open'ing something in terminal) - you could source the default list in your current terminal session:

source /usr/share/applications/defaults.list
Rik
  • 191
  • 1
    This has got to be the oldest thread I’ve seen revived, 7 years later – nick Aug 30 '22 at 13:48
  • 1
    @nick It's a good question because it can stump people who've used Debian/Ubuntu for even longer; and 7 years later the answer(s) can/will change. You should never hesitate to answer a question regardless of its age; especially if the question exists already - and the historic answer doesn't work any longer. People are encouraged not to repeat questions; stack has evolved its products so that answers may stack according to most recent upvotes (recent preference changes, you may have noticed). In a sense revival isn't really a thing, because ongoing support is supported/expected. – Rik Aug 31 '22 at 14:11
3

The file manager choice is handled by a file in ~/.local/share/applications. They are mimeapps.list and mimeinfo.cache, deleting both of those files will reset your file manager to the default, which is Nautilus.

Bus42
  • 364
RolandiXor
  • 51,541
1
  1. sudo mv /usr/bin/nemo /usr/bin/nemo.backup
  2. Open any folder. You could use xdg-open /path/to/folder/ while in the command line, for example. Or you could use a X application that requests a file.
  3. A dialog should appear to you requesting a default application to be your file manager. Type /usr/bin/nautilus there and confirm.

After that, as long as you don't rename nemo to its original name/location, nautilus will be your default file manager again.

thiagowfx
  • 845
  • 6
  • 9