Hello world
Let’s start out with a “simple” example. In the code editor on your right, you’ll find the script hello.sh, which outputs Hello world to the screen.
The more detail-oriented among you may have noticed the quotes around the word “simple”, and you’d be right to think something’s up because this script doesn’t run!
Try it yourself:
You’ll see a Permission denied error, but don’t worry, this is an error most of us run into, even after years of using the command line.
It happens because when you create a new file in Linux, you only have permissions to read (r) and write (w) it, but not execute (x) it.
For that, you need to explicitly grant yourself (u) permission to do so:
Then run the script again:
Now it’s working as expected!
Most people just use chmod +x without the u, but keep it mind that gives execute permissions to all users on the system, which is fine on your laptop but can be a problem on shared servers, where you might not want anyone else to run your scripts.