Home Interests Raspberry Pi

How to Make a Shell Script Executable on the Raspberry Pi

howchoo
howchoo   (467)
August 17, 2023
3 minutes

Share

Interests
Posted in these interests:
linux • 12 guides
pi • 92 guides

If you’ve ever tried running a shell script, only to get a command not found error, it probably means your shell script isn’t executable:

sudo ./install.sh

This very short guide will show you how to make a shell (.sh) script executable on your Raspberry Pi. This assumes your Pi is running Raspberry Pi OS or some other Linux/Unix-based operating system.

1 – Navigate to the file

Navigate to the path of the directory where the file is:

cd ~/some/directory

You can confirm that the file is not executable by running ls -la, and observing there’s no x (for executable):

-rw-r--r--  1 pi pi   684 Dec 16 17:28 install.sh

2 – Make the script executable

To make the script executable, use the chmod command:

sudo chmod +x install.sh

If you run ls -la, you’ll see the file is now executable:

-rwxr-xr-x  1 pi pi   684 Dec 16 17:28 install.sh

You’ll now be able to execute the script successfully:

sudo ./install.sh

It’s worth mentioning that the file doesn’t have to be executable to run it. You can also use sudo sh install.sh, but making it executable is handy in order to execute the script directly.

NEXT UP

How to Run a Minecraft Server on the Raspberry Pi

A whole world trapped inside your Pi.
howchoo   (467)
December 7, 2023

There are several ways to go about running a Minecraft server on the Raspberry Pi. In this guide, I’ll cover how to install Nukkit—a cross-platform Minecraft server that’s super easy to set up on the Raspberry Pi. This server should work with PCs, consoles, and tablets running Minecraft 1.14. I’ll be using a Raspberry Pi

Continue Reading

howchoo

 467 guides

Introducing Howchoo, an enigmatic author whose unique pen name reflects their boundless curiosity and limitless creativity. Mysterious and multifaceted, Howchoo has emerged as a captivating storyteller, leaving readers mesmerized by the uncharted realms they craft with their words. With an insatiable appetite for knowledge and a love for exploration, Howchoo's writing transcends conventional genres, blurring the lines between fantasy, science fiction, and the surreal. Their narratives are a kaleidoscope of ideas, weaving together intricate plots, unforgettable characters, and thought-provoking themes that challenge the boundaries of imagination.

Discover interesting things!

Explore Howchoo's most popular interests.

Explore