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?

1

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.