LXC.EXEC(1)

πŸ“¦
version 5.21.6 Β· 3 versions
, in opensuse-leap 16.0

πŸ’– 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 using su -l, most environment variables will be reset. so if your carefully exported PATH ghosted 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 (default 0) πŸ¦‹
  • --mode="auto" β€” Override the terminal mode (auto, interactive or non-interactive) 🌈
  • --user=0 β€” User ID to run the command as (default 0) πŸ’œ

🧚 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 --help to 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 by spf13/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