Today we’re going to learn something important, that is how to make a file executable. This is something everyone should know how to do. It’s not going to be easy to make this into an article, ’cause it’s really quite easy, but I’ll give it a shot.
One of the important things about Linux is that files have various permissions. You can read, write, and execute a file based on the permissions. This helps keep Linux a bit more secure, because files can’t be executed until you’ve given them permission to do so.
I’ll make this article as straightforward as I can, by trying to give you an example of how this works. We’ll create a file, make it executable, and then run said file. This should serve as a good example, so that you can do so in the future.
You’ll see a bunch of commands in this article. If you’re new, just follow ’em until the end and you’ll hopefully understand what’s going on, and see how to make a file executable. Trust me, this isn’t something all that taxing. I’m sure you can get it!
Make A File Executable:
This article requires an open terminal, like many other articles on this site. If you don’t know how to open the terminal, you can do so with your keyboard – just press
With your terminal open, let’s create a new file. We’ll do that with:
love.sh for editing with nano by using the following command:
Enter the following text:
echo "I love Linux Tips!"
Now, you’ll have to save that. Just press
Now, we’ll make the file executable with the ‘
chmod‘ command. That’s done with this command:
chmod +x love.sh
With that done, all you need to do now is execute the file. To do that, you just call the file by name in the terminal. As you’re still in the same directory, you’ll need to use ./ – so your command actually looks like:
With that, you should get a message saying that you love Linux Tips. Aww… Isn’t that sweet of you! We love you too! It was also a fun way to create a file, edit it, make it executable, and then actually executed said file.
See? That wasn’t all that hard. I hope that method shows you a little about how to make a file executable. It’s a pretty basic skill that all Linux users should be familiar with. It’s not a very complicated article, but that’s just fine. At least we (hopefully) had some fun with it.
Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your own site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.