Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Ive been following a tutorial and Ive come to a part about writing and executing shellcode. It told me to create a file called myfile.sh, and then to run the command "chmod 0755 myfile.sh". I did this, and it appeared to work; it turned the file name green when I view it with the ls command. Well, anyway, it then told me to open it up and write a few shell script commands into it just to basically get the hang of executing these files. So I wrote a simple shell script, just echoing some things, and then I saved it. Well, when I tried to run it via "./myfile.sh" it gave me the following error:
-bash: ./myfile.sh: bin/sh: bad interpreter: No such file or directory
The no such file or directory part didnt seem to make much sense to me, because I can see that the file IS there. I also tried making another file and doing the exact same thing but without the chmod part. That gave me a "Permission denied" error message. I then thought that maybe I didnt have sufficient permission on this account, so I switched to root and tried again and got the same results. I have tried everything I can think of, but maybe its something that should be obvious. I have only had linux a few days, so Im still learning.
If anyone can help me out with this, Id really appreciate it. Until then Ill just skip over this part of the tutorial. Thanks.
Ah, we have a winner... my script origionally was just this:
#!bin/sh
echo "Hello there!"
But now I changed it to
#!/bin/sh
echo "Hello there!"
And it works perfectly fine... now I can continue with this tutorial. Thanks for the help, I was definitely looking for this problem in the wrong place.
I had a similar problem but the solution for me was different. I was going through the script tutorial on my Windows workstation and had copied and pasted the "Hello World" script into my windows text editor and then SSH'd the script to my Linux box. I was getting the same "bad interpreter" error unitil I opened the script again in a linux editor and resaved it. It turns out that linux uses a different end of file marker than DOS/Windows and the script would not run until it had been corrected for linux.
You can also use: dos2unix < oldfile > newfile
to convert the dos/windows file to a valid linux file.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.