From the course: Learning Linux Shell Scripting

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

chmod

chmod - Linux Tutorial

From the course: Learning Linux Shell Scripting

Start my 1-month free trial

chmod

- [Instructor] Let's take a look at our hello.sh script again. Open it using Atom. Atom hello.sh. For fun, let's add another message to it. Let's add a line below echo Hello, World, add whatever you'd like. I'm gonna add echo Mars is red. Control S to save. And now I'm gonna return to the terminal and to run it I'm gonna type bash hello.sh. The response is predictably unsurprising. Okay, I know what you're thinking. Why do I have to type bash in order to execute my script? Good question. The answer is because files by default don't have the execute permission. Don't believe me? Let's try it together. ./hello.sh. We get an error message. Permission denied. If we'd like to make a file executable, we must use the change mode command, let's do that now. We type chmod 755 hello.sh. This gives everyone the permission to read and execute the script but only the owner permission to write it. Okay, let's try it again. ./hello.sh. Okay, that worked but why do we have to type ./ before the name…

Contents