UNIX alike systems like Linux or MacOS do not run any executable files just because they have a specific extension. To make a file directly executable it needs to have the executable-bit set (
chmod +x file) which will not be done done automatically when saving the attachment.
Still, there are many kinds of files which desktop environment on top of Linux (and other OS) like GNOME, KDE,... will automatically open. This is for one based on the file extension similar to what Windows does, i.e. *.doc files will be opened with some office suite, *.pdf with a PDF-Viewer etc. If the extension is missing then most desktop environments will look at the "magic" of the files, i.e. use libmagic to determine the kind of file and open it in the appropriate application. On MacOS there is also an additional mechanisms where the file type and application is includes as attributes (fork) in addition to the file but these information are usually lost when transferring a file through mail (although some archiving programs preserve these attributes).
But, it will NOT automatically mark downloaded files executable and run them. It will also not directly execute shell-script, Perl-Scripts, Python-Scripts etc which don't have the execute-bit explicitly set.
It is though possible that you've downloaded an archive and extracted it. Specific kind of archive formats (like Tar, usually with extensions like *.tar, *.tgz and similar) will include file permissions like the executable bit and these will be usually preserved when extracting the archive. In this case no additional setting of the executable bit is needed and a program could be directly executed.
Thus, withstanding bugs in PDF viewer, Office application or similar applications which are automatically started when you click on a file and withstanding archives, you are generally more safe in Linux since it will not automatically start programs downloaded from somewhere. On the other hand, applications could set a special attribute to files in Windows to specify that the origin of the file is not trusted, which causes Windows to ask for confirmation before executing the file.
If you still want to filter for executable files in attachments you might use libmagic or the libmagic based tool file to detect the file type. Note that these are only heuristics and detection might in theory return a different type, especially for very similar file types (like all the ZIP based office documents, JAR files, ZIP files..). But given that ELF binaries or files with an explicit interpreter definition on top (i.e.
#!/usr/bin/python) have a clear structure one can rely on these heuristics for these file types.
Apart from that note that recent Windows versions not only use the file extension to determine what to do with the file. If the file has no extension which is associated with an application it will try to detect the file type without extension similar to how it is done in Linux.