Maybe someone here would be able to help me out. Have installed Ubuntu 12.04 LTS (kubuntu) on two machines. The .bashrc and .bash_profile files are identical as the file structures on each machine is the same.

On machine 1 I run bash scripts within a terminal window with the simple: ./scriptname.sh

On machine 2, I cannot do this and must use: sh scriptname.sh Nor can I use ./ and tab-complete the script filename.

All executable bits are set correctly, all files and folders have the correct permissions. In the header of the scripts the shebang is set correctly.

Any ideas why this would be occurring?


  • also asked on unix&linux and stackoverflow – glenn jackman Nov 5 '12 at 1:50
  • Is this for root, or a non-root user? Does echo $SHELL on both machines confirm that the shell is bash? – Lars Rohrbach Nov 5 '12 at 1:56
  • non-root user, echo $SHELL returns /bin/bash on both machines – adeliefan Nov 5 '12 at 2:01

The only thing that would cause this is if the script is not executable. I know you said the executable bit is set, but make sure:

chmod +x scriptname.sh
  • Nope - its definitely set right. I figure there has to be something wrong with my environmental set up (.bashrc or .bash_profile) but cant see where it has snuck in. – adeliefan Nov 5 '12 at 2:08

The errors you see may be caused by trying to run an executable on a media mounted with the "noexe" property. Type mount, and examine the properties of the device which contains the script. Change the /etc/fstab properties of the mount if necessary.

  • Thanks. I have need to changed properties to ext4 rw,relatime – swist Sep 27 '18 at 11:09

I've read of various problems arising with auto-completion, not necessarily with 12.04, and the following two options seem worth trying:

First, try disabling bash programmable completion: Comment-out these three lines in both /etc/bash.bashrc and in the user's $HOME/.bashrc:

 if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
     . /etc/bash_completion

You may find that those lines are already commented-out with # in front, in which case just leave it as-is.

So secondly, try re-installing bash-completion:

sudo apt-get purge bash-completion
sudo mv /etc/bash_completion.d /etc/bash_completion.d.bak
sudo apt-get install bash-completion
  • Thanks for the suggestion Lars, it made no difference though. – adeliefan Nov 5 '12 at 2:18
  • Well, darn. I presume you re-logged-in after doing this? – Lars Rohrbach Nov 5 '12 at 2:27

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.