lxc exec

Execute commands in instances

Synopsis

Description: Execute commands in instances

The command is executed directly using exec, so there is no shell and shell patterns (variables, file redirects, …) won’t be understood. If you need a shell environment you need to execute the shell executable, passing the shell commands as arguments, for example:

lxc exec <instance> -- sh -c "cd /tmp && pwd"

For interactive sessions, a convenient ‘shell’ alias is provided to spawn a login shell inside the instance:

lxc shell <instance>

This ‘shell’ alias is a shorthand for:

lxc exec <instance> -- su -l

Note: due to using ‘su -l’, most environment variables will be reset.

Mode defaults to non-interactive, interactive mode is selected if both stdin AND stdout are terminals (stderr is ignored).

lxc exec [<remote>:]