ZRJ
ZRJ

Reputation: 181

how does linux execute a file

First I chmod +x to these following files forcibly, and when I tried to execute a PNG file in linux, I got the error like this:

: command not found.png: line 1: ‰PNG
./default_1920x1200.png: line 2: : command not found
IHDR€0Wö: command not foundne 3:
./default_1920x1200.png: line 4: OiCCPPhotoshop: command not found
./default_1920x1200.png: line 4: *!: command not found
./default_1920x1200.png: line 5: Øä!¢Žƒ£ˆŠÊûá{£kÖ¼÷æÍþµ×: command not found
./default_1920x1200.png: line 5364: warning: here-document at line 9 delimited by end-of-file (wanted `+À¾xÓ
                                                                                                           ÀM›À0‡ÿêB™\€„Àt‘8€@zŽB¦@F€&S `ËcbãP-`æÓ€WW.(ÎI+6aaš@.Ây™24àóÌ ‘àƒóýxήÎÎ6Ž¶_-ê¿ÿbbãþåÏ«p@át~Ñþ,/³€;€mþ¢%îh^

But when I try to execute a JPG or a BMP file, I can get a normal error like

-bash: ./s_x-r.bmp: cannot execute binary file

So I wonder how does the linux kernel execute a file?

Upvotes: 0

Views: 253

Answers (1)

It is exactly documented in execve(2) man page.

You can register additional ways thru the binfmt_misc directory inside /proc/sys/fs/

(Your desktop might have additional ways to "run" an application when you click on it)

Upvotes: 3

Related Questions