LXC.EXEC(1)
π LXC-EXEC π
okay bestie so you're reading the LXD - Command line client(1) page, specifically the one for lxc-exec, and honestly? it's giving "tiny command, huge power" β¨ stick with me and we'll get you executing things inside your instances like it's nothing π«Ά
πΈ NAME πΈ
lxc-exec β Execute commands in instances π
β¨ SYNOPSIS β¨
lxc exec [:] [flags] [--]
π¦ DESCRIPTION π¦
the vibe: Execute commands in instances π₯
so here's the thing β the command is executed directly using exec, which means there's no shell in the middle, and shell patterns (variables, file redirects, ...) won't be understood. ngl this trips people up every single time π 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"
see how we're literally calling sh and handing it the whole string? that's the move π
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 usingsu -l, most environment variables will be reset. so if your carefully exportedPATHghosted you, that's why π
mode defaults to non-interactive, interactive mode is selected if both stdin AND stdout are terminals (stderr is ignored) π
π OPTIONS π
--cwd=""β Directory to run the command in (default/root) π-n,--disable-stdin[=false]β Disable stdin (reads from/dev/null) π--env=[]β Environment variable to set (e.g.HOME=/home/foo) β¨-t,--force-interactive[=false]β Force pseudo-terminal allocation π-T,--force-noninteractive[=false]β Disable pseudo-terminal allocation πΈ--group=0β Group ID to run the command as (default0) π¦--mode="auto"β Override the terminal mode (auto,interactiveornon-interactive) π--user=0β User ID to run the command as (default0) π
π§ OPTIONS INHERITED FROM PARENT COMMANDS π§
these are the ones that come from the parent, lowkey the whole family is iconic π
--debug[=false]β Show all debug messages π₯--force-local[=false]β Force using the local unix socket π-h,--help[=false]β Print help π«Ά--project=""β Override the source project β-q,--quiet[=false]β Don't show progress information π--sub-commands[=false]β Use with help or--helpto view sub-commands πΈ-v,--verbose[=false]β Show all information messages π£--version[=false]β Print version number π’
π SEE ALSO π
lxc(1)β go read it, iykyk π
π HISTORY π
22-Aug-2026β Auto generated byspf13/cobraπ€
aaaand that's the whole thing, bestie, you ate that πβ¨ this page was Auto generated by spf13/cobra, dated Aug 2026, from the one and only LXD - Command line client(1) β now go forth and exec responsibly ππ
π¦
π¦ where this page comes from
- opensuse-leap 16.0: lxd 5.21.6-bp160.1.1 Β· AGPL-3.0-only AND Apache-2.0
- opensuse-leap 16.0: lxd 5.21.6-bp160.1.1 Β· AGPL-3.0-only AND Apache-2.0
- opensuse-leap 16.0: lxd 5.21.6-bp160.1.1 Β· AGPL-3.0-only AND Apache-2.0
- opensuse-leap 16.0: lxd 5.21.6-bp160.1.1 Β· AGPL-3.0-only AND Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms