I'm trying to understand how Linux handles file extensions. Since Linux generally doesn't use extensions to determine a file's type, I created an empty file with `touch banana.jpg`, added plain text to it with `nano`, and confirmed the contents with `cat`.
However, running `less banana.jpg` produced a message like "No identify available" and suggested installing ImageMagick instead of showing the text. Why is `less` doing this, and how can I make it display the file contents normally?
3 Answers
You can check whether the helper is enabled with `env | grep LESSOPEN`. To bypass it for one command, use the `-L` option:
`less -L banana.jpg`
You can also disable the configured preprocessor in your current shell with:
`unset LESSOPEN`
After that, `less banana.jpg` should display the file as ordinary text. The `.jpg` suffix itself does not force Linux to treat the file as an image; the extra `less` integration is what is causing this.
The behavior isn’t universal. On some installations, `less` has no image-handling integration at all, so it will simply show the text regardless of the `.jpg` suffix. For example, if `lesspipe` isn’t configured through `LESSOPEN`, a file named `file.jpg` containing `foo` will just display `foo`.
So the result depends more on the distribution’s `less` setup than on Linux itself or the filename extension.
This is usually caused by `lesspipe`, a helper script that some distributions configure `less` to use. It can inspect filenames and extensions, then invoke other tools for compressed files, images, archives, and metadata. The `LESSOPEN` environment variable tells `less` which preprocessor to run, so the behavior depends on your distribution and its configuration.

That explains it—thanks. I didn’t realize environment variables could change how a command preprocesses its input.