Score:1

Exec format error with "data" file format

cn flag

Does anyone knows why it gives format error when i try to run echo through /bin/echo or /usr/bin/echo but works well if i just type echo in the command line

bash: /usr/bin/echo: cannot execute binary file: Exec format error

The output file /bin/echo

/bin/echo: data

What's that data file format why i cant execute it.

Here is the screenshot, Screenshot

hr flag
When you just type `echo` in the command line, you are most likely getting your interactive shell's built-in implementation of the the command
Mr Syhd avatar
cn flag
@steeldriver but when i run "which echo" the output is /usr/bin/echo, also can i make the echo script inside bin folder just same as the built in implementation ? so that it doenst give me executable error
hr flag
`/bin/echo` should work - it sounds like the file has become corrupted. Perhaps you can fix it by re-installing the `coreutils` package.
Mr Syhd avatar
cn flag
@steeldriver thanks, reinstalling the coreutils package fix the problem
Mr Syhd avatar
cn flag
@steeldriver but there's something that bother my head, you just said `echo` in the command line might be the built in implementation, but why when i run `which echo` the output is `/usr/bin/bash` which is the problematic file, do you know why?
hr flag
No I don't know why - I would expect `which echo` to output `/usr/bin/echo` (or `/bin/echo` on a pre-usrmerge system). FYI `which` will only show you external executables - try `type -a echo` instead. See also [Why not use "which"? What to use then?](https://unix.stackexchange.com/questions/85249/why-not-use-which-what-to-use-then)
Mr Syhd avatar
cn flag
@steeldriver oh i see, thanks for the answer
Mr Syhd avatar
cn flag
lol yeah the output should be /usr/bin/echo, typo
Score:4
in flag

There is likely something wrong with your /bin/echo, as you should get something like this when running file on it:

/bin/echo: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=714b557112010bbcd04b0e5e6efc1b106166733c, for GNU/Linux 3.2.0, stripped

We can see that coreutils is the package that is supposed to provide /bin/echo by running:

dpkg -S /bin/echo

And finally you can check to ensure that none of the files of the package has been modified or corrupted by running:

sudo apt install debsums
debsums coreutils

If any of the files are corrupted you can re-install them using:

sudo apt install coreutils --reinstall
Mr Syhd avatar
cn flag
detailed answer, thanks!!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.