'How to make a binary executable able to write anywhere on linux?

I am writing a tool for all users on a linux server, which can download files from somewhere and save them to current directory. I build this tool as sudo user vector to get a binary executable and ask others to use alias tool="path/to/binary" to access that executable. However this executable cannot write files other than in folders under home directory of vector. How can I do to make it accessable to all users and have permissions to write to their directory?



Solution 1:[1]

When you create the tool, vector can own it. The tool should reside somewhere on the user's PATH. /usr/bin or /usr/local/bin are usually included the PATH. You can check the path with echo $PATH to see what it is set to.

Check the permissions to make sure it is executable by everyone. chmod 755 /path/to/binary

When the user executes the tool, it should execute as the user.

Make sure the output of the tool is not hard-code to a location the user does not have access to write.

If you can have it write to STDOUT, then the user can redirect the output to a place of their choosing

cmd> /path/to/binary > ~/output.txt

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dan Obregon