how does linux execute a file

Go To


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?

2012-04-04 16:59
by ZRJ
What are you trying to accomplish executing a jpeg - Captain Giraffe 2012-04-04 17:01
Sorry, I just out of curiosit - ZRJ 2012-04-04 17:05


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)

2012-04-04 17:00
by Basile Starynkevitch