1

I am working in the latest version of Ubuntu and am very new to coding and StackOverflow.

I created a simple script to echo "Hello World".

The script's name is helloworld.sh

#!/bin/sh

echo "Hello World"

I try to run it using sudo ./helloworld.sh, but receive the following prompt:

sudo: ./helloworld.sh: command not found

What am I doing wrong here?

jonroethke
  • 1,152
  • 2
  • 8
  • 16
  • Possible duplicate of [Command not found when using sudo](https://stackoverflow.com/questions/12996397/command-not-found-when-using-sudo) – Benjamin W. Jan 22 '19 at 00:47

1 Answers1

0

Try: chmod +x helloworld.sh

You can determine the specific file permissions by running ls -l, which will now show that you have executable permission for the file helloworld.sh, allowing you to run it with ./.

If you do not have permission to change mode (chmod), try running your script as sh helloworld.sh.

Lastly, you shouldn't need to be running with sudo unless there are some strict permissions set on the account.

Benjamin W.
  • 46,058
  • 19
  • 106
  • 116
jonroethke
  • 1,152
  • 2
  • 8
  • 16
  • That last point should be emphasized: there's no reason to use `sudo`, and you should never use `sudo` (or otherwise do anything with `root` permissions) unless there's a valid reason to do so. – Keith Thompson Jan 22 '19 at 04:53