2 ms·
Out of curiosity I checked what Files (the desktop app) and file (the CLI tool) do in Ubuntu 20.04. Files says that image.png is a PNG image $ file image.pn
by pmontra 6y ago
Out of curiosity I checked what Files (the desktop app) and file (the CLI tool) do in Ubuntu 20.04.
Files says that image.png is a PNG image
$ file image.png
image.png: PNG image data, 965 x 720, 8-bit/color RGB, non-interlaced
$ mv image.png program.exe
According to Files it's a DOS/Windows executable. If I try to open it from there it opens Archvie Manager and displays an error dialog. And yet
$ file program.exe
program.exe: PNG image data, 965 x 720, 8-bit/color RGB, non-interlaced
$ eog program.exe
It loses bash autocompletion on program.exe but eog opens the image.
$ mv program.exe sound.mp3
Files reports it as MP3 audio. It opens in the sound player program (it has no nome on screen) and does nothing. Of course file correctly identifies the file as PNG. eog sound.mp3 works.
$ mv sound.mp3 text.pdf
Files says it's a PDF document and opens it in evince, which fails with an error message. eog text.pdf works
A suggestion to Files' authors: check the magic file definition, not the extension, especially when opening files.
What I use extensions for: to remember what a file is, by the name of it when doing ls in the terminal. The extension is more to help me than the OS. I open most of the files I work with by the command line, not in Files. Another reason is that if I send the file to somebody else I want to make it easy for them. So screenshot-2020-11-16_1000.png and not screenshot-2020-11-16_1000 which maybe breaks some of their tools. Third reason: some files must have an extension: header.h, program.c, program.o, program and not header and code, code, code :-)
And yes, programs in *NIX never had extensions. So ls / and not ls.exe /