I'd like to ask for reconsideration on an edit I suggested; based on this meta question, I believe Meta is where such a request belongs.
The post in question is an answer to a question I asked, What does the double-hyphen do in `lxc exec`.
I thought PeterVanHeusden's answer was precise and thorough (also kind, since as he said, there's an argument to be made that my question was a duplicate, only I haven't realized what's actually behind the behavior I was seeing), but it did have some formatting issues.
muru corrected those, but in so doing s/he also made a change which I feel needs to be rolled back:
- The question dealt with LXD; PeterVanHeusden made an example involving a shell in both the host and the container, and used the shell prompt to distinguish the two (in a container, typically one gets a
root@container:~#
prompt). muru felt it was "unnecessarily long", and edited it to a simple$
prompt. Also note that, as KazWolfe mentions below, PeterVanHeusden specified in the text which part works in which context. However, I object to the edit on two grounds: (a) it makes the example less clear, rather than more so (a graphic cue really helps there), and (b) the$
prompt doesn't appear inside a container, because by default one executes commands as root in it (includingbash
, to get a shell into it); this just adds to the confusion, and the space saved by shrinking the prompt does't help in this case (there's more than enough space in the answer).
Additionally, (something I mistakenly thought muru changed, but was in the original)
A
sudo
call was used in the example to run the LXD command-line toollxc
, which is redundant. From LinuxContainers.org:The package creates a new "lxd" group which contains all users allowed to talk to lxd over the local unix socket. All members of the "admin" and "sudoers" groups are automatically added. If your user isn't a member of one of these groups, you'll need to manually add your user to the "lxd" group.
This implies that any user able to escalate
sudo
should already be able to calllxc
; moreover, the preferred way of gaining privileges is to add a user to the "lxd" group, rather than usingsudo
.Keep in mind the following two points: (a) using
sudo
for tasks which don't require it is a bad habit to encourage. (b) A user following this example has already installed LXD and launched a container. All tutorials I've seen, including those on Ubuntu Insights written by Stéphane Graber (project head), use unprivileged containers that don't requiresudo
. If for some reason users find themselves in a situation wheresudo
is required to manage LXD, they quite surly already know why and how that happened.Hence, I contend that almost everyone, and most particularly novices, are safe to remove the
sudo
call from the example, and therefore it's better not to include it.
I believe the two reviewers who rejected my edit (to roll these changes back, while keeping the changes to format) might not have looked at the edit history, nor realized that it's (now, partially) a roll-back. I might be wrong, but I believe the answer is better with the two changes I suggested. (To me it is, in any case.)
sudo
to anything.