2

Trying to run an executable file on terminal (I am using Tails live OS), but I keep receiving an error message. I have set permissions already. The command I wrote:

sudo ./home/amnesia/myfile

I receive "Command not found"?

I tried running it with or without sudo:

$ sudo /home/amnesia/myfile
sudo: unable to execute /home/amnesia/myfile: No such file or directory
$ /home/amnesia/myfile
bash: /home/amnesia/myfile: No such file or directory

Information about the file (it's a binary, not a script):

$ ls -l /home/amnesia/myfile
-rwxrwxrwx 1 amnesia amnesia 15327 Sep  3  2013 /home/amnesia/myfile
$ file /home/amnesia/myfile
ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared lies), for GNU/Linux 2.6.9, not stripped

Information about my system:

$ uname -a
Linux amnesia 3.16-3-amd64 #1 SMP Debian 3.16.5-1 (2014-10-10) x86_64 GNU/Linux
$ file /bin/ls
/bin/ls: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0xd3280633faaabf56a14a26693d2f810a32222e51, stripped
  • What is the content of myfile? – Faheem Mitha Nov 8 '14 at 5:02
  • Does myfile have a proper shebang line? – PM 2Ring Nov 8 '14 at 5:55
  • If this is a binary blob (as opposed to a script), maybe it's this issue. – Joseph R. Nov 8 '14 at 11:40
  • @JosephR., my processor is 64 bit and the file is also 64 bit. So I don't think its that issue. – Hodurrr Nov 8 '14 at 17:32
  • 1
    Can you run the program without sudo? What is the output of ldd /home/amnesia/myfile? @JosephR. More precisely, I suspect this issue. – Gilles Nov 8 '14 at 22:19
2
$ /home/amnesia/myfile
bash: /home/amnesia/myfile: No such file or directory
$ file /home/amnesia/myfile
ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared lies), for GNU/Linux 2.6.9, not stripped

So myfile exists, but running it gives the message “No such file or directory”. This happens in the following circumstance:

  • The file depends on a loader — it's a dynamically linked executable, and these need a loader program to load the dynamically linked libraries. (The loader can also be the interpreter designated by a shebang line, but bash detects this case and gives a different error message.)
  • The loader file is not present.

The message “No such file or directory” is really about the loader, but the shell doesn't know that the loader is involved, so it reports the name of the original file. I explain this in more detail in “No such file or directory” lies on Optware installed binaries.

Why can't you run this program? Because you don't have the dynamic loader for 64-bit executables.

$ uname -a
Linux amnesia 3.16-3-amd64 #1 SMP Debian 3.16.5-1 (2014-10-10) x86_64 GNU/Linux
$ file /bin/ls
/bin/ls: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0xd3280633faaabf56a14a26693d2f810a32222e51, stripped

Your system has a 64-bit kernel, but the rest of the system is 32-bit. Linux supports this configuration (a 64-bit kernel can run both 64-bit programs and 32-bit programs, but a 32-bit kernel can only run 32-bit programs). The kernel can load the program just fine; you would be able to run a statically-linked amd64 executable. However, you don't have the 64-bit loader (/lib64/ld-linux-x86-64.so.2), nor presumably any 64-bit library. So you can't run dynamically-linked amd64 executables.

Why would you run a 64-bit kernel with a 32-bit userland?

  • To use more than about 3GB of physical memory. (This isn't the only way — another possibility is to run a 32-bit kernel that supports PAE.)
  • To be able to run 64-bit binaries, e.g. by booting on the live OS and then chrooting into an installed 64-bit system somewhere.
  • To reduce maintenance effort for the distribution: provide a single kernel for recent hardware, and make it 64-bit.
  • To run 64-bit virtual machines (some VM engines require a 64-bit kernel to run a 64-bit VM).

I don't think Tails provides a 64-bit system. You should get a 32-bit version of the executable. If you can't, use some other distribution (possibly in a virtual machine).

  • Great answer! this is what exactly I was looking for! – Leonardo Rossi Jan 22 '15 at 10:43
0

if you havent: chmod

chmod u+x /home/amnesia/myfile

And remove the '.' from the begning. it needed when you in same directory as of file is

sudo /home/amnesia/myfile

here is demo: Demo

  • chmod u+x worked fine, but it still won't execute. – Hodurrr Nov 8 '14 at 2:15
  • what the output of ls -l /home/amnesia/myfile – Hackaholic Nov 8 '14 at 2:17
  • Output is -rwxrwxrwx 1 amnesia amnesia ... – Hodurrr Nov 8 '14 at 2:18
  • show the code of script in your post – Hackaholic Nov 8 '14 at 2:19
  • If permissions were the problem, the error message would be “Permission denied”. – Gilles Nov 10 '14 at 17:03
0

I suggest checking the following:

  • Run file /home/amnesia/myfile. This will determine the file type you are trying to execute;
  • Run the script without sudo to get a more meaningful message;
  • If it's something like a shell script, a set -x will also help you figure out what's going on. You can also run the script with sh -x;
  • Could be a broken shebang line (ex: bad interpreter). Paste the output of head -5 /home/amnesia/myfile;
  • Could be that you have 'DOS' newlines in your script. If that file is a script with DOS newlines, a simple dos2unix myfile or perl -pi -e 's/\r\n/\n/g' input.file may fix the problem;
  • Okay I put 'file /home/amnesia/myfile' and the output is: 'ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared lies), for GNU/Linux 2.6.9, not stripped' – Hodurrr Nov 8 '14 at 16:45
0

I had the same problem. On Debian 7.8 the fix was to install the lsb package:

apt-get install lsb

I had to install a similar package (don't remember exactly which) on CentOS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.