'alias' + sudo

Polytropon freebsd at edvax.de
Thu Sep 3 00:28:55 UTC 2009

On Wed, 2 Sep 2009 15:06:48 -0500, Dan Nelson <dnelson at allantgroup.com> wrote:
> sudo does not run root's shell at all; it directly runs whatever is given it
> on the commandline.

Another idea would to be to call sudo with the desired shell as
argument (in order to inherit the aliases), followed by a command
as argument to the shell (in order to execute a particular command),
something like

	% sudo bash -c "my_command_alias"

It may be possible that bash requires an additional argument to tell
it to read ~/.bashrc when invoked in a non-interactive manner.

Keep in mind that I haven't tried this solution because I don't
use bash on a regular basis.

Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...

More information about the freebsd-questions mailing list