How to create make your scripts executable form everywhere
create a folder at the base of your home directory
1
2
3
4
cd ~ # go to your home directory
mkdir NAME_OF_FOLDER # create your new folder
touch helloworld.sh # create your firts scripts
nano helloworld # Open your file
Content of helloworld.sh
1
2
3
#!/bin/sh # use shell scripting
echo "Hello world!" # Print hello world! on your terminal
- Open the
.bashrc
file in your home directory (for example,/home/your-user-name/.bashrc
) in a text editor. - Add
export PATH="your-dir:$PATH"
to the last line of the file, where your-dir is the directory you want to add. - Save the
.bashrc
file. - Restart your terminal.
Now you can run your scripts form everywhere on your terminal