The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

If you can read me, I'm broken!

Views: 2,028,408β€…    Votes:  2β€…
Tags: command-line   executable  
Link: πŸ” See Original Answer on Ask Ubuntu ⧉ πŸ”—

URL: https://askubuntu.com/q/1364586
Title: How to make a file (e.g. a .sh script) executable, so it can be run from a terminal
ID: /2021/09/19/How-to-make-a-file-_e.g.-a-.sh-script_-executable_-so-it-can-be-run-from-a-terminal
Created: September 19, 2021
Upload: April 21, 2025    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false


Let all users run your script

As stated you can set the execution bit of the file to make it executable with chmod +x. But you can also use chmod a+x:

$ ll file_command.txt
-rw-rw-r-- 1 rick rick 17 Sep 19 08:55 file_command.txt

$ chmod a+x file_command.txt

$ ll file_command.txt
-rwxrwxr-x 1 rick rick 17 Sep 19 08:55 file_command.txt*

NOTES:

make script executable


Run a script without making it executable

You can still run a bash script without making it executable. For example:

$ echo "echo Hello World" > file_command.txt

$ cat file_command.txt
echo Hello World

$ bash file_command.txt
Hello World

NOTES:

⇧ HDMI monitor stops working when lap top lid is closed Should I use MBR or GPT when I intend to use both Ubuntu and Windows?  β‡©