This means that you are trying to execute a binary file using your bash script which is not intended to be run as you trying it to be. It is already a binary file and you are trying your $SHELL to parse and run it.
in a very simple example, if you try to run `w' command like
$ bash w
/usr/bin/w: /usr/bin/w: cannot execute binary file
similarly you might be hitting the same method or as it looks from your code snippet.
While , for the remaining for your commands, Al these halt, shutdown , reboot etc commands are the root owned commands and need super-user prilveges to run and perform the required operation. normal users can't run them
another explanation is that these commands are placed at /sbin/ and /usr/sbin , which might not be in your $PATH variable ( which is used to validate commands in your custody )
8What did you do to that machine? – slhck – 2012-06-12T21:32:02.227
1the very last thing I did was install logwatch. Nothing else. – superuser – 2012-06-12T21:33:00.303
can you
export PATH=/bin:/usr/bin:/sbin:/usr/sbin
? Can the shell find halt/poweroff/reboot then? (Note, I'd advise not shutting down the system unless you know you can bring it back up, or have accepted that you might have to boot from a live-CD and fix everything manually) – Darth Android – 2012-06-12T21:37:24.040what does "export PATH=/bin:/usr/bin:/sbin:/usr/sbin" do? – superuser – 2012-06-12T21:39:15.397
3
PATH
is an environment variable which contains a list of folders which the shell searches for programs.ls
for example, usually refers to/bin/ls
, and your shell finds it by going through the folders listed inPATH
one-by-one until it finds it, or if it doesn't find it in any of them, it gives up. I suppose a better starting point would be, what is the output ofecho $PATH
? (edit: theexport
command is a way to define an environment variable in bash.) – Darth Android – 2012-06-12T21:41:31.110The reason I ask is because a few minutes ago, I wasn't even able to "poweroff" the machine. After doing "export PATH=/bin:/usr/bin:/sbin:/usr/sbin", it didn't do anything. So I tried "poweroff" again, and somehow it was able to be shutdown. – superuser – 2012-06-12T21:44:03.753
Right now, it's pingable but not sshable. I'm just glad I have a backup of everything. – superuser – 2012-06-12T21:47:44.323
1Ah... I warned you not to shut the system down :P Can you get console access to it (physical monitor+keyboard attached)? Try booting the system in single-user mode (might be labelled as recovery mode) and see if you can get to a root shell. – Darth Android – 2012-06-12T21:51:28.207
2@David you won't see any output after typing
export PATH=/bin:/user/bin:/sbin:/usr/sbin
. It's a silent command. – Ben Richards – 2012-06-12T21:57:44.987