[Edit - Save your time. Better rendering of the situation at this entry]

I've got a script with a shebang that works on Ubuntu Mate, but not on Lubuntu Minimal (+LXDE).

I can't quite get what I need from searches, and I'm now overwhelmed.

My first (ever!) script, written on my host Ubuntu Mate (xenial) machine, worked beautifully easily. That version is at the end of this post.

I took the same script to my VM Lubuntu Minimal machine, (rewrote it manually - no sharing), and ran into trouble.

In Lubuntu Minimal I've tried the following shebangs, gleaned from various forums:

#!/bin/bash works fine in the host


#!/usr/bin/env bash

which yield (mostly):

bash: /home/user/bin/script1: [the path part of the shebang, e.g./bin/bash/]: bad interpreter: not a directory

I've restarted the machine once or twice, and used chmod +x and chmod 700 - checking with 'ls -l' shows the same permissions as the working version on Ubuntu Mate.

I've tried naming the script script1.sh as well as just script1. I've called it using /.script1 and /.script1.sh, to no result. (I don't know what these /. and sh exactly do, nor for what process).

I've placed the script file in:

/usr/local/bin (which I think I had to create, from memory)

~/Desktop just to see

~/bin (and I did indeed have to create this)

Some forum talked about $PATH and rebooting, so I've rebooted a couple of times (but I don't understand $PATH).

The only (partial) success comes from removing the shebang and saving that script in ~/bin.

Two problems:

  1. I just can't understand why. What critical thing is missing from Lubuntu Minimal that Ubuntu Mate has? If I just create, say a `/bin/bash' directory, will bash magically find its way there, do nothing, or will I break it?

  2. Ultimately, I want this to run from a .desktop launcher, but initial experiments fail - using Exec=script1 in the desktop entry makes a terminal window flash up then close, instantly. Previously I've used bash -c "cmd1 && cmd2 &&..." in Lubuntu, but bash is throwing an error here. Intuitively, I guess that's because I removed 'bash' from the shebang, but see problem 1., above.

My head is now pretty tangled, and I'm not sure where to start reading to get on top of this. Your wisdom would be appreciated.

Thanks in advance

Original test script (works in Ubuntu Mate):


#host to block
echo -e "enter domain to block:"
read host_name  
echo -e $host_entry >>/home/user/Desktop/host-edits-test
echo "***done and gone***" 
sleep 2
exit 0
  • 2
    Have you check if /bin/bash exist in Lubuntu? And !# is not the correct syntax, the correct one is #! – Romeo Ninov Dec 14 '17 at 9:08
  • 1
    #!/bin/bash -- (without the final bar) – JJoao Dec 14 '17 at 9:08
  • 1
    Is your test script executable? You may need to chmod u+rx it. Also read wikipage on PATH (variable). You might perhaps need to edit some file like your ~/.bashrc to permanently change it for interactive shells, but YMMV – Basile Starynkevitch Dec 14 '17 at 9:31
  • 2
    Bah, put in the question the exact information of what you did and the exact error messages. None of this "mostly" stuff. This is computing, not human communication: single characters have meaning, and single-character typos can and will change the meaning to something essentially different. The computer can't know what you meant, neither can the readers of your question. – ilkkachu Dec 14 '17 at 12:17
  • If you've replaced this question with an alternative one, please either delete this one or accept an answer that most helped you (use the tick-mark next to the up/down votes beside the answer). – roaima Dec 19 '17 at 23:17

As the comments already pointed out, you seem to have a couple of problems at once:

  1. The correct shebang syntax is #!, but this seems just to be a typo in your question, not the script.
  2. A final slash indicates a directory, that's why you get the message

    bad interpreter: not a directory

  3. Ubuntu in all its variants uses dash as default shell; you may have to install bash manually.

Your "original test script" looks right so far, just make sure bash is installed and you should be fine.

Or, if you don't rely on bashisms in your scripts, change the shebang to point to /bin/sh which usually is a link to the current system shell, in this case probably dash; this is the most portable solution.



You seem trying to solve multiple problems in parallel, and mix up several issues in your question. So, one problem after the other:

  1. Make sure the bash package is installed.
  2. Make sure /bin/bash is indeed an executable binary.
  3. Make sure you can call /bin/bash as user, and get a working command line.
  4. Check that you can run a simple script that just consists of the shebang and some echo.

If you get this far with everything working, the problem is most probably found in your actual script, not the system setup or bash binary. And if you encounter any issues, update your question with a precise description and output, and skip the rest for the time being. Or better yet, create a new question, as this one is already quite messed up.

  • 6
    Debian and Ubuntu use dash as /bin/sh, but Bash is still always installed (as /bin/bash). It's an "essential" package which makes it very hard to not install. – ilkkachu Dec 14 '17 at 12:10
  • What about Lubuntu Minimal? – Murphy Dec 14 '17 at 12:30

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.