Vahid Vahid - 7 months ago 12
Linux Question

Always call a binary with a specific flag in linux

I was wondering if there is any way to execute a binary in linux, always with a specific flag.

For example, whenever

executes, I want it always executes with
flag. So, issuing the
in console, results in
genisoimage -allow-limited-size

won't work as the binary is called from another one


Yep! What you're looking for is a Bash alias.

Just add alias genisoimage="genisoimage -allow-limited-size" to your ~/.bashrc (or ~/.bash_profile for macOS) file.

For more info on the Bash alias, check out

EDIT: Given that another script or application calls genisoimage.

If it's being called form another script or application, you're going to have to change the genisoimage that's resolved within that script/application. Here's how you may be able to accomplish this.

First, Create your own genisoimage which adds your -allow-limited-size flag. This will go in to a file named genisoimage at /some/other/path and must be made executable (i.e. chmod u+x /some/other/path/genisoimage). Suppose that the genuine genisoimage file is located at /bin/genisoimage

#! /bin/bash
/bin/genisoimage -allow-limited-size "$@"

The above adds the desired flag, and passes all arguments along to the origin genisoimage.

Now when you run your script/application, change the PATH variable so the file you just created is found first.

$> PATH=/some/other/path:$PATH ./APPLICATION