Ubuntu ошибка file not found

Is it a script or a binary executable?

If it’s a script, check the #! line.

Depending on your shell, the error message for a command with a bad #! line can refer to the script rather than to the missing interpreter.

For example, using tcsh:

% cat foo
#!/bin/no_such_interpreter

echo hello
% chmod +x foo
% ./foo
./foo: Command not found.
%

Using bash, the error message is different:

$ chmod +x foo
$ cat foo
#!/bin/no_such_interpreter

echo hello
$ ./foo
bash: ./foo: /bin/no_such_interpreter: bad interpreter: No such file or directory
$

Even if the #! line looks ok, it can fail if there’s a r character at the end of the line, which can often happen if the file was created on Windows. What does

head -1 blah-blah.bin | cat -A

show you?

If that doesn’t solve the problem, show us exactly what command you typed and the error message that resulted.

EDIT : I realize your title suggests it’s a binary executable. Exactly what kind of file is it? What is the output of

file blah-blah.bin

?

I simply want to run an executable from the command line, ./arm-mingw32ce-g++, but then I get the error message,

bash: ./arm-mingw32ce-g++: No such file or directory

I’m running Ubuntu Linux 10.10. ls -l lists

-rwxr-xr-x 1 root root  433308 2010-10-16 21:32 arm-mingw32ce-g++

Using sudo (sudo ./arm-mingw32ce-g++) gives

sudo: unable to execute ./arm-mingw32ce-g++: No such file or directory

I have no idea why the OS can’t even see the file when it’s there. Any thoughts?

asked Oct 16, 2010 at 14:00

Warpspace's user avatar

This error can mean that ./arm-mingw32ce-g++ doesn’t exist (but it does), or that it exists and is a dynamically linked executable recognized by the kernel but whose dynamic loader is not available. You can see what dynamic loader is required by running ldd /arm-mingw32ce-g++; anything marked not found is the dynamic loader or a library that you need to install.

If you’re trying to run a 32-bit binary on an amd64 installation:

  • Up to Ubuntu 11.04, install the package ia32-libs.
  • On Ubuntu 11.10, install ia32-libs-multiarch.
  • Starting with 12.04, install ia32-libs-multiarch, or select a reasonable set of :i386 packages in addition to the :amd64 packages.

answered Oct 16, 2010 at 14:25

Gilles 'SO- stop being evil''s user avatar

10

I faced this error when I was trying to build Selenium source on Ubuntu. The simple shell script with correct shebang was not able to run even after I had all pre-requisites covered.

file file-name # helped me in understanding that CRLF ending were present in the file.

I opened the file in Vim and I could see that just because I once edited this file on a Windows machine, it was in DOS format. I converted the file to Unix format with below command:

dos2unix filename # actually helped me and things were fine.

I hope that we should take care whenever we edit files across platforms we should take care for the file formats as well.

fantaghirocco's user avatar

answered Sep 23, 2015 at 9:29

Jitendra's user avatar

JitendraJitendra

7066 silver badges10 bronze badges

4

This error may also occur if trying to run a script and the shebang is misspelled. Make sure it reads #!/bin/sh, #!/bin/bash, or whichever interpreter you’re using.

answered Jan 27, 2014 at 20:24

Zoltán's user avatar

ZoltánZoltán

21.2k14 gold badges92 silver badges133 bronze badges

3

I had the same error message when trying to run a Python script — this was not @Warpspace’s intended use case (see other comments), but this was among the top hits to my search, so maybe somebody will find it useful.

In my case it was the DOS line endings (rn instead of n) that the shebang line (#!/usr/bin/env python) would trip over. A simple dos2unix myfile.py fixed it.

answered Feb 23, 2015 at 15:50

djlauk's user avatar

djlaukdjlauk

3,1791 gold badge12 silver badges12 bronze badges

1

I found my solution for my Ubuntu 18 here.

sudo dpkg --add-architecture i386

Then:

sudo apt-get update
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386

answered May 15, 2020 at 15:37

betontalpfa's user avatar

betontalpfabetontalpfa

3,3841 gold badge32 silver badges65 bronze badges

1

As mentioned by others, this is because the loader can’t be found, not your executable file. Unfortunately the message is not clear enough.

You can fix it by changing the loader that your executable uses, see my thorough answer in this other question: Multiple glibc libraries on a single host

Basically you have to find which loader it’s trying to use:

$ readelf -l arm-mingw32ce-g++ | grep interpreter
  [Requesting program interpreter: /lib/ld-linux.so.2]

Then find the right path for an equivalent loader, and change your executable to use the loader from the path that it really is:

$ ./patchelf --set-interpreter /path/to/newglibc/ld-linux.so.2 arm-mingw32ce-g++

You will probably need to set the path of the includes too, you will know if you want it or not after you try to run it. See all the details in that other thread.

answered Jul 11, 2019 at 21:52

msb's user avatar

msbmsb

3,7793 gold badges30 silver badges38 bronze badges

2

I got this error “No such file or directory” but it exists because my file was created in Windows and I tried to run it on Ubuntu and the file contained invalid 15r where ever a new line was there.
I just created a new file truncating unwanted stuff

sleep: invalid time interval ‘15r’
Try 'sleep --help' for more information.
script.sh: 5: script.sh: /opt/ag/cont: not found
script.sh: 6: script.sh: /opt/ag/cont: not found
root@Ubuntu14:/home/abc12/Desktop# vi script.sh 
root@Ubuntu14:/home/abc12/Desktop# od -c script.sh 
0000000   #   !   /   u   s   r   /   b   i   n   /   e   n   v       b
0000020   a   s   h  r  n   w   g   e   t       h   t   t   p   :   /

0000400   :   4   1   2   0   /  r  n
0000410
root@Ubuntu14:/home/abc12/Desktop# tr -d \015 < script.sh > script.sh.fixed
root@Ubuntu14:/home/abc12/Desktop# od -c script.sh.fixed 
0000000   #   !   /   u   s   r   /   b   i   n   /   e   n   v       b
0000020   a   s   h  n   w   g   e   t       h   t   t   p   :   /   /

0000400   /  n
0000402
root@Ubuntu14:/home/abc12/Desktop# sh -x script.sh.fixed 

answered Jan 14, 2016 at 15:09

likeGreen's user avatar

likeGreenlikeGreen

1,0071 gold badge19 silver badges38 bronze badges

I got the same error for a simple bash script that wouldn’t have 32/64-bit issues. This is possibly because the script you are trying to run has an error in it. This ubuntu forum post indicates that with normal script files you can add sh in front and you might get some debug output from it. e.g.

$ sudo sh arm-mingw32ce-g++

and see if you get any output.

In my case the actual problem was that the file that I was trying to execute was in Windows format rather than Linux.

answered Nov 27, 2013 at 14:58

icc97's user avatar

icc97icc97

11.1k8 gold badges72 silver badges88 bronze badges

Below command worked on 16.4 Ubuntu

This issue comes when your .sh file is corrupt or not formatted as per unix protocols.

dos2unix converts the .sh file to Unix format!

sudo apt-get install dos2unix -y
dos2unix test.sh
sudo chmod u+x test.sh 
sudo ./test.sh

answered Apr 20, 2018 at 9:27

Soumyaansh's user avatar

SoumyaanshSoumyaansh

8,5567 gold badges44 silver badges44 bronze badges

I had the same problem with a file that I’ve created on my mac.
If I try to run it in a shell with ./filename I got the file not found error message.
I think that something was wrong with the file.

what I’ve done:

open a ssh session to the server

cat filename
copy the output to the clipboard

rm filename
touch filename
vi filename
i for insert mode
paste the content from the clipboard
ESC to end insert mode
:wq!

This worked for me.

answered Oct 12, 2014 at 21:44

space's user avatar

spacespace

211 bronze badge

1

Added here for future reference (for users who might fall into the same case):
This error happens when working on Windows (which introduces extra characters because of different line separator than Linux system) and trying to run this script (with extra characters inserted) in Linux. The error message is misleading.

In Windows, the line separator is CRLF (rn) whereas in linux it is LF (n). This can be usually be chosen in text editor.

In my case, this happened due to working on Windows and uploading to Unix server for execution.

answered Jan 24, 2020 at 2:54

PALEN's user avatar

PALENPALEN

2,7542 gold badges23 silver badges24 bronze badges

1

I just had this issue in mingw32 bash. I had execuded node/npm from Program Files (x86)nodejs and then moved them into disabled directory (essentially removing them from path). I also had Program Filesnodejs (ie. 64bit version) in path, but only after the x86 version. After restarting the bash shell, the 64bit version of npm could be found. node worked correctly all the time (checked with node -v that changed when x86 version was moved).

I think bash -r would’ve worked instead of restarting bash: https://unix.stackexchange.com/a/5610

answered Jul 15, 2016 at 8:31

Pasi Savolainen's user avatar

Pasi SavolainenPasi Savolainen

2,4401 gold badge22 silver badges35 bronze badges

I had this issue and the reason was EOL in some editors such as Notepad++. You can check it in Edit menu/EOL conversion. Unix(LF) should be selected.
I hope it would be useful.

answered Sep 22, 2019 at 12:04

user3184564's user avatar

1

Hit this error trying to run terraform/terragrunt (Single go binary).

Using which terragrunt to find where executable was, got strange error when running it in local dir or with full path

bash: ./terragrunt: No such file or directory

Problem was that there was two installations of terragrunt, used brew uninstall terragrunt to remove one fixed it.

After removing the one, which terragrunt showed the new path /usr/bin/terragrunt everything worked fine.

answered Dec 14, 2020 at 20:46

Pieter's user avatar

PieterPieter

1,88717 silver badges17 bronze badges

For those encountering this error when running a java program, it’s possible that you’re trying to run a 64-bit java program using on a 32-bit linux operating system.

I only realised when I ran ldd on 64-bit java which reported:

ldd /usr/java/jdk1.8.0_05/bin/java

‘not a dynamic executable’

Whereas the old 32 bit java reported sensible results:

ldd /usr/java/jdk1.8.0_05/bin/java

answered Jan 22, 2022 at 7:52

keithphw's user avatar

keithphwkeithphw

3801 gold badge4 silver badges14 bronze badges

In a .sh script, each line MUST end with a single character — newline (LF or «n«).

Don’t make mistakes like me, because my text-editor of choice is Notepad++ in Win.
The default line ending in Win is «rn» (CR LF), and such ending is not standard for Linux shell scripts.

answered Dec 16, 2022 at 22:20

Bokili Production's user avatar

In my case, it turns out the file was a symlink:

$ cat deluge-gtk.lock
cat: deluge-gtk.lock: No such file or directory
$ file deluge-gtk.lock
deluge-gtk.lock: broken symbolic link to 32309

Misleading errors like this are fairly common on Linux. Related discussion: https://lwn.net/Articles/532771/

answered Nov 2, 2021 at 5:01

Navin's user avatar

NavinNavin

3,6462 gold badges28 silver badges52 bronze badges

Give it a try by changing the name of file or folder which is not showing in terminal/command prompt.

step1 : change the name of file or folder.
step2 : cd filename/foldername

answered Nov 21, 2021 at 19:10

SHACHI PRIYA's user avatar

2

For future readers, I had this issue when trying to launch a Django server using gunicorn. I was using AWS CodeBuild to build the virtual environment and run tests and using CodeDeploy to put the built artifacts onto the production server and launch the new version (all environments were Ubuntu 20.04). I had mistakenly thought that env/bin/... contained actual binaries of native libraries but that was not the case. It was just Python scripts with a shebang of the path to the Python interpreter on the build machine. In my case, the machine installing the packages and actually running the packages was different. To be more specific, all of the files in env/bin had the shebang #!/codebuild/output/src715682316/src/env/bin/python, so of course running env/bin/gunicorn on the production server would fail. The cryptic error message was when Ubuntu would tell me that env/bin/gunicorn didn’t exist as opposed to saying /codebuild/output/src715682316/src/env/bin/python didn’t exist. I was able to fix this problem by starting gunicorn using python3 env/bin/gunicorn instead of env/bin/gunicorn.

answered May 22, 2022 at 20:17

Badr B's user avatar

Badr BBadr B

9181 gold badge8 silver badges17 bronze badges

This: sed -i -e 's/r$//' FILE, could potentially fix your problem.

As many answers already have explained, this issue could be caused by line endings being rn in Windows and only n in Linux. A suggested approach was to use dos2unix. As far as I understand this is not standard on most Linux distributions, and in my case I could not install / use it.

Therefore I used the following approach, (mentioned in Bash script – «/bin/bash^M: bad interpreter: No such file or directory»), where you can use the sed command instead.

sed -i -e 's/r$//' FILE where you replace FILE with the name of your file, e.g. sed -i -e 's/r$//' myscript.sh

If you for some reason do not have sed installed but do not want to use dos2unix you can use the following to install sed:

sudo apt-get update
sudo apt-get install sed

answered Mar 30 at 13:38

darclander's user avatar

darclanderdarclander

1,5061 gold badge12 silver badges35 bronze badges

1

Yet another possible reason: the file is a binary linked dynamically against musl (most likely for alpine)

on debian system you will have to install

apt-get update -y && apt-get install -y musl musl-dev musl-tools

answered Apr 14 at 11:15

Daniel Braun's user avatar

Daniel BraunDaniel Braun

2,39326 silver badges25 bronze badges

I just installed quite a lot of 12.10 updates, was prompted to reboot, and then found that I couldn’t boot.

Braiam's user avatar

Braiam

66.7k30 gold badges176 silver badges264 bronze badges

asked Sep 14, 2012 at 20:20

8128's user avatar

1

Use Boot Repair to fix your bootloader.

  1. Boot Ubuntu from a LiveCD or Live USB
  2. Connect to the internet
  3. Open a terminal, and add the Boot Repair PPA

    sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update

  4. Install Boot Repair

    sudo apt-get install -y boot-repair && boot-repair

  5. Launch and use, see https://help.ubuntu.com/community/Boot-Repair#Using_Boot-Repair for more details

answered Oct 19, 2012 at 22:09

8128's user avatar

81288128

28.6k27 gold badges110 silver badges145 bronze badges

4

  1. Type ls to get a list of partitions
  2. Enter set prefix=(hd0,msdos6)/boot/grub [you will almost certainly have to enter a different drive/partition in the brackets, you may just have to try all of those listed by ls until you find the one that works.
  3. Type insmod normal
  4. Type normal and you will get your boot prompt back!

See also: The helpful place where I found this. I doubt this will work for everyone encountering this error, but I’ve put it here in the hope it helps someone.

Once you’ve loaded Ubuntu, run sudo grub-install /dev/sda and sudo update-grub as soon as possible. This means you won’t have to do that tedious process above every time you boot your machine.

answered Sep 14, 2012 at 20:20

8128's user avatar

81288128

28.6k27 gold badges110 silver badges145 bronze badges

3

I had the exact same issue — normal.mod not found, ls of the boot partition would produce a blank line. After a week of troubleshooting to get the system to boot properly here are the steps I went through.

  1. Got a copy of SuperGrub and created a boot cd. I could now get logged back on to my system. Got a copy of BootRepair and had not luck getting the system to boot directly from the hard disk and had to keep using the CD. BootRepair did act a little strange since the Grub location and Grub options were grayed out. It did report a successful install.

  2. Hard drive was originally set up:
    sda1 ext4 root with boot
    sda2 linux swap
    sda3 ext4 used as a spare drive (holds VMs for Virtual box).

  3. Used a copy of Ubuntu 10.10 live cd. Ran gparted Install gparted to shrink the sda1 partition and created sda4 ext4 boot partition at the front of the drive and set mount point to /boot after deleting the boot directory from /. BootRepair now has options available. Installed on boot partition and can now boot from hard drive.

  4. Being curious I decided to investigate further. The boot repair log had a peculiar entry for my sda1 ext4 partition, it was reported as DOS and had a short 8 character UUID instead of the UUID reported by blkid. grub-probe reported the file system as vfat.

  5. After many other trials I cleared the first 440 bytes of sda1 partition record. Grub-probe now reports file system as ext2. Ran update-grub and the correct UUID for the sda1 partition appears.

The issue seems to be two-fold:
1. It seem to affect installations where the partition record has references to msdos.
2. grub-probe does not try to resolve mismatch issues between fs type and contents in the partition record.

Community's user avatar

answered Nov 13, 2012 at 15:33

Mark Milakovic's user avatar

Another thing to check is the boot order in your BIOS. I apparently had installed grub installed on all my disks (perhaps after following 8128’s answer), but this broke when updating my Linux distro (Debian). Changing the first boot disk as my Linux OS fixed it.

answered Oct 23, 2014 at 15:05

Jonathan's user avatar

JonathanJonathan

2111 silver badge7 bronze badges

I ran across this error upgrading to Kubuntu 13.10. I had a memory stick plugged into the USB port during the dist-upgrade. After rebooting I went straight to Grub Rescue. Unplugging the USB drive and rebooting fixed the problem.

answered Oct 19, 2013 at 5:38

David Walker's user avatar

In my case, I had downgraded to GRUBv1 and after the upgrade to 12.10 grub2 couldn’t find his files (*.mod, etc…), although the grub.cfg was there.

I found a more comprehensive manual on grub rescue:
https://help.ubuntu.com/community/Grub2/Troubleshooting#grub_rescue.3E-1

See also the command list at the begining of the page.
Thx flute flute.

answered Nov 17, 2012 at 14:16

iceburn_pt's user avatar

running an Ubuntu 14.04 x64, I like to execute an binary file. This one:

$ ls -la /opt/android-sdk-linux/tools/emulator
-rwxrwxr-x 1 tho tho 35640 Nov 19 14:46 /opt/android-sdk-linux/tools/emulator

If I run the executable as user tho, the following file not found error occours:

$ /opt/android-sdk-linux/tools/emulator
bash: /opt/android-sdk-linux/tools/emulator:  no such file or directory

I tried the following commands:

$ file /opt/android-sdk-linux/tools/emulator
/opt/android-sdk-linux/tools/emulator: ELF 32-bit LSB  executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped

readelf -l emulator returned without any errors.

ldd emulator says, that this program is not dynamically linked

$ strace  /opt/android-sdk-linux/tools/emulator
execve("/opt/android-sdk-linux/tools/emulator", ["/opt/android-sdk-linux/tools/emu"...], [/* 64 vars */]) = -1 ENOENT (No such file or directory)
write(2, "strace: exec: No such file or di"..., 40strace: exec: No such file or directory
) = 40
exit_group(1)                           = ?
+++ exited with 1 +++

What could be the reason for that error?

Unlike other operating systems such as Windows, Linux is an OS in which the majority of its tasks are performed using the Terminal. One of the major tasks that the Linux terminal performs is the execution of programs using commands. While attempting to execute any program through this method, the user may come across this very common error statement which is the “no such file or directory” issue.

This article will elaborate on the reasons that prompt the error “no such file or directory” and also provide possible solutions to fix it

How to Resolve the “no such file or directory”?

Since this is a very general error, there are a few different reasons that can invoke this issue on the system. All these reasons are discussed below in great detail.

Reason 1: Wrong File Name

The first and the most commonly occurring reason is caused by using incorrect spellings of the file name. For example, the mistake can be the incorrect spelling of a file. Below is an example of such a mistake:

$ bash sampl.sh

Solution: Check the File name and Path

In the example shown above, the bash file “sample.sh” is saved on the desktop. So, make sure that the error is not invoked by using the correct spellings and the correct path. Look at the following image where the name and path of the file are correct, and thus, the output is displayed:

$ bash sample.sh

Reason 2: Wrong File Format

The other most common cause behind this issue is that the file that is attempted to execute is in a different format than the operating system. Let’s take an example of this situation. The file that is executed using the command is a DOS file which is a script written for Windows. If this DOS file is executed in an Ubuntu system, the “no such file or directory” issue will be invoked.

Solution: Use the dos2unix Tool

There exists a very useful tool for exactly these types of scenarios. The dos2unix tool helps to convert a dos file to a script that can be read by the Ubuntu OS. The first step is to install the dos2unix tool using this command:

$ sudo apt install dos2unix

Once the tool is installed, convert the DOS file into an Ubuntu-compatible file using the following command:

$ dos2unix sample.dos

The system should be able to run the script file without the error being prompted after the conversion is complete.

Conclusion

The “no such file or directory” issue occurs when the name or the path of the executable file is entered incorrectly into the terminal. Another reason is that Ubuntu is not able to read the DOS script and if it is executed on the Ubuntu terminal, then the error is prompted. To fix these issues it needs to be made sure that the file path and file name are entered correctly into the terminal. The other fix is to install the dos2unix tool and convert the dos files format to run on Ubuntu. This article has demonstrated the reasons and the solutions to fix the error “no such file or directory”.

Понравилась статья? Поделить с друзьями:
  • Ubuntu обнаружена ошибка в системной программе как исправить
  • Ubuntu не устанавливается пакет ошибка
  • Ubuntu не удалось получить временная ошибка при разрешении
  • Ubuntu как проверить флешку на ошибки
  • Ubuntu как проверить файловую систему на ошибки