How to Execute Shell Script in Linux?

Open a terminal

Navigate to the script directory using `cd`

Make the script executable with `chmod +x script.sh`

Run the script with `./script.sh`

Or run it with `bash script.sh`

Or run it with `sh script.sh`

Use the full path if needed, such as `/path/to/script.sh`

Ensure the script starts with a valid shebang, such as `#!/bin/bash`

Suggested for You

Trending Today