DEV Community

Paul Walker
Paul Walker

Posted on • Originally published at solarwinter.net on

Exploring file types in Linux

My setup

Exploring file types in Linux

I don't actually run a Linux desktop, strictly speaking - I use MobaXTerm on my Windows laptop to ssh in. Moba runs an X server, so I can open windows from the Linux machine as if they were native Windows ... windows.

(I feel that sentence got away from me a little.)

My Linux usage is probably slightly atypical, but I'm willing to bet there's quite a few of us doing that now.

The problem

Recently I had a problem getting Firefox to open a file manager window. Since it was opening a filer window, rather than a specific file type, the usual Firefox settings didn't help me.

Brief tangent... MIME types

If you don't want to know the why, skip to the next section. ๐Ÿ˜Š

MIME is (strictly speaking) an email standard. MIME types are a general/specific pair describing the nature of a resource. For example:

  • text/html
  • image/jpeg
  • application/octet-stream

It turns out that (a) the database of file types that's been built up is quite extensive, and (b) this is useful for helping programs other than email apps to know how to handle something.

The solution

We finally got there.

The MIME type of a directory? inode/directory

(โ€œWhat's an inode?โ€ is a whole other post... the Wikipedia article will have to do for now!)

So - what I needed was to change the default program used to open that type. Enter xdg-mime:

xdg-mime default nemo.desktop inode/directory 

Enter fullscreen mode Exit fullscreen mode

(Note: the tool takes .desktop files rather than the program path.)

Useful extras

I also found a couple of other useful things:

  1. file -bi will give you fileโ€™s best guess at a MIME type
  2. xdg-open should act like open does on macOS, which is great as I find that really useful.
  3. There's a whole ton of stuff in this area if people are curious for more.

(Post image thanks to Alexander Sinn.)

Latest comments (0)