suq
is a Perl script that uses the command line arguments passed to it to
form a properly quoted command string that is then passed to su
to be
executed as root. It is desgined as an alternative to the common usage of
sudo
to execute a single command with root privileges. This is useful for
systems on which sudo
is not installed or is unnecessary.
suq [options] [command]
[options]
is one of --help
or --version
[command]
is the string that will be executed with root permissions
If an [option]
is found, the rest of the command string will be ignored.
suq
's behavior is controlled by the following environment variables:
SUQ_NOLOGIN=1
do not pass '-l' to suSUQ_PRESERVE=1
pass "-m" to suSUQ_SHELL='shell'
pass "-s shell" to suSUQ_SIMULATE=1
print the command; don't run itSUQ_USER='name'
run command as "name" instead of root
Set the environment variable SUQ_SIMULATE
in order to prevent suq from
actually executing the command (the command will only be printed).
Example:
% export SUQ_SIMULATE=1; suq perl -le 'print "foo"'
su -l -c 'perl -le '\''print "foo"'\' root
%
The default value of all aforementioned ENV variables is undefined
. Setting a
value to ''
or 0
will cause it to be ignored (i.e. return it to the default
value) except for SUQ_USER
, which is treated as a string. To reset it:
export SUQ_USER='root'
Sting::ShellQuote
(Debian packagelibstring-shellquote-perl
)- Perl 5.10 or newer
su
(Debian packagelogin
)
Visit https://github.com/dbb/suq for the README or to report any issues.