Running a Script
Chmod +x and ./.
A script is a text file full of commands. You'll write lots of them later in this course. For now, let's see what it takes to actually run one, because permissions play a big part.

- A script: a file of commands
- More on them later
- How to run one
Not allowed, yet
We go into the scripts folder. To run a program from the current folder, you type dot slash, and its name. But we get permission denied. The file isn't executable yet. There's no X in its permissions.
cd projects/scripts ./hello.sh bash: ./hello.sh: Permission denied ls -l hello.sh -rw-r--r-- 1 sam sam 40 Jan 5 09:00 hello.sh
Making it executable
CH mod plus X gives execute permission to everyone. When you leave out the who, it applies to all. Now dot slash hello dot SH runs, and prints its message. That's all it takes to turn a text file into a program.
chmod +x hello.sh ls -l hello.sh -rwxr-xr-x 1 sam sam 40 Jan 5 09:00 hello.sh ./hello.sh Hello from my script
Why dot slash?
Why the dot slash? When you type a plain name, like LS, the shell only looks in a list of program folders. Your current folder isn't on that list, for safety. Dot slash means, run the file in this folder, right here. We'll learn about that list of folders, called the path, later.
| key | value |
|---|---|
| ls | found in program folders |
| hello.sh | not found: not in the list |
| ./hello.sh | run it from here |
| Safety | the current folder isn't searched |
Summary
To run a script, make it executable with CH mod plus X, then run it with dot slash and its name. Next, file owners, and how to change them.
Key takeaways- chmod +x script
- ./script
- No x: permission denied