I'm trying to convert a simple batch script into a package. According to my (limited) understanding of packaging, this would mean that I would store the script in /usr/bin.

The problem is, the batch script uses a different sh script stored somewhere else. The sh script cannot be run as a sudo, and the sh script needs to read/write to files in the directory of the sh script. What this means is that I need to have a location to store this script (and the files it uses) without requiring sudo. Would this be possible?

(BTW, as the script also downloads files to the users home directory (~), I can't make someone run the script with sudo because file ownership is then incorrectly handled with the downloaded files. Unless that would be fixable.)


Manual Execution

You can execute the command using bash /path/to/your.sh. If you set the file as executable ( chmod +x /path/to/your.sh ), then you can do /path/to/your.sh and it will automatically run under bash. You will need to make sure your script has a shebang.



$PATH is an environmental variable that lists all of the locations in which you would like to search for binaries when running a command.

This is how /usr/bin is used for binaries.

You can see your current $PATH by opening a terminal and running echo $PATH.


As the example above reads, the paths have priorities; first searched first. This means that if there are two versions of a binary, the one in the first path will be used. Once a binary is found, it stops searching on other directories in your $PATH.

If you attempt to run banana, your computer is going to look at /most/important/path. If it finds banana, it will run it. If not, it will continue searching, moving on to /less/important/path.


To add directories to your user's path, you could add them to your ~/.bashrc file. Instead of overwritting and messing up your path, you should append to it. For example:

export $PATH=${PATH}:/new/less/important/directory

Or you can prepend to set it as the highest-priority directory:

export $PATH=/new/more/important/path:${PATH}

To prevent issues, you should probably only append (first example).

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.