I'm trying to understand how Linux handles file extensions. I created a file with `touch banana.jpg`, then added plain text to it with `nano`. `cat banana.jpg` shows the text normally, but running `less banana.jpg` displays a message such as "No identify available" and suggests installing ImageMagick to browse images. Why is `less` treating the file as an image, and how can I make it display the file contents as ordinary text?
2 Answers
Check whether `LESSOPEN` is set with `env | grep LESSOPEN`. You can bypass the configured preprocessor for one command with `less -L banana.jpg`, or disable it in the current shell with `unset LESSOPEN`. After that, `less` should read the file directly and show the text, regardless of its `.jpg` name. The exact result can vary between distributions because not every system enables `lesspipe`.
Linux itself generally doesn’t use the `.jpg` suffix to determine a file’s type. However, many systems configure `less` to use a helper called `lesspipe`. The `LESSOPEN` environment variable points to that helper, which may inspect the filename extension and invoke programs for images, archives, compressed files, and other formats. This behavior depends on the distribution and its `less` configuration, so another system may display the text normally.

That gives me a useful lead— I’ll look into environment variables and how `LESSOPEN` is configured.