- No such file or directory? But the file exists!
- 9 Answers 9
- How to Fix “bash: no such file or directory”
- How to Resolve the “no such file or directory”?
- Reason 1: Wrong File Name
- Solution: Check the File name and Path
- Reason 2: Wrong File Format
- Solution: Use the dos2unix Tool
- Conclusion
- Problem when trying to run shell script : No such file or directory
- 4 Answers 4
No such file or directory? But the file exists!
I’ve downloaded a game (Shank) but the bin file doesn’t run. The error that is shown when I try to launch the executable is:
bash: ./shank-linux-120720110-1-bin: No such file or directory
Thank you for your reply. I’ve done the command you said Agent86 but I have the same result. I’ve downloaded also the .deb file but there is a problem too. I don’t know what problem has this game.
Please confirm whether you’re running a 64-bit installation (that’s the most common case for this problem).
9 Answers 9
You’re probably trying to run a 32-bit binary on a 64-bit system that doesn’t have 32-bit support installed.
There are three cases where you can get the message “No such file or directory”:
- The file doesn’t exist. I presume you’ve checked that the file does exist (perhaps because the shell completes it).
- There is a file by that name, but it’s a dangling symbolic link.
- The file exists, and you can even read it (for example, the command file shank-linux-120720110-1-bin displays something like “ELF 32-bit LSB executable …”), and yet when you try to execute it you’re told that the file doesn’t exist.
The error message in this last case is admittedly confusing. What it’s telling you is that a key component of the runtime environment necessary to run the program is missing. Unfortunately, the channel through which the error is reported only has room for the error code and not for this extra information that it’s really the runtime environment that’s to blame. If you want the technical version of this explanation, read Getting “Not found” message when running a 32-bit binary on a 64-bit system.
The file command will tell you just what this binary is. With a few exceptions, you can only run a binary for the processor architecture that your release of Ubuntu is for. The main exception is that you can run 32-bit (x86, a.k.a. IA32) binaries on 64-bit (amd64, a.k.a. x86_64) systems.
In Ubuntu up to 11.04, to run a 32-bit binary on a 64-bit installation, you need to install the ia32-libs package . You may need to install additional libraries (you’ll get an explicit error message if you do).
Since 11.10 (oneiric) introduced multiarch support, you can still install ia32-libs , but you can choose a finer-grained approach, it’s enough to get libc6-i386 (plus any other necessary library).
How to Fix “bash: no such file or directory”
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:
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:
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:
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”.
TUTORIALS ON LINUX, PROGRAMMING & TECHNOLOGY
Problem when trying to run shell script : No such file or directory
rvm is a bash file, and it does run ok when I attempt to run it from its own folder ( production_x86_64-linux ). It works also fine if I attempt to run it when opening the terminal in its parent folder, for instance, or even its parent-parent folder. I’ve run it over with dos2unix just in case and I’ve also checked its executing permissions, which seem to be fine. What am I missing here?
4 Answers 4
you can run a bash script by using the following command
bash /home/abcdef/Desktop/jikesrvm/dist/production_x86_64-linux/rvm
what basically the . means is your current directory location.
if you are under your folder then try doing this
./Desktop/jikesrvm/dist/production_x86_64-linux/rvm
it will work but first you should make the file executable using the following command
chmod +x ~/Desktop/jikesrvm/dist/production_x86_64-linux/rvm
I am also facing similar issue. I have an executable (.ish) file located deep in directory. So, I have set an alias in my bash. When I try to run it from other directory, it shows error. Let me show: pro@prasanta-desktop:~$ studio bash: ./home/pro/Downloads/Software/studio.ish: No such file or directory in my bash, I have defined, alias studio=’./home/pro/Downloads/Software/studio.ish’ However, going in that directory and running ./studio.ish runs the program perfectly, what can be the issue then?
./home/abcdef/Desktop/jikesrvm/dist/prototype_x86_64-linux/rvm
shell will always treat . in front of a path as current directory and hence the path will always be a relative path. So, shell is trying to find an executable file in the location:
$PWD/home/abcdef/Desktop/jikesrvm/dist/prototype_x86_64-linux/rvm
which is wrong as you can see. You would run a executable script that is the current directory as ./script.sh .
You can actually simply run the executable by using the absolute path (given the script is executable):
/home/abcdef/Desktop/jikesrvm/dist/prototype_x86_64-linux/rvm
Or as ~ is expaneded by shell as $HOME :
~/Desktop/jikesrvm/dist/prototype_x86_64-linux/rvm
Or even just the name of the script if the directory containing the script is in the PATH environment variable.
Now if your script is Not executable, you can run it too without making it an executable by telling the shell which program will handle the script i.e. giving the script as an argument to bash (shell):
bash /home/abcdef/Desktop/jikesrvm/dist/prototype_x86_64-linux/rvm