When I run commands under k3s kubectl, I get
$ k3s kubectl version
WARN[0000] Unable to read /etc/rancher/k3s/k3s.yaml, please start server with --write-kubeconfig-mode to modify kube config permissions
error: error loading config file "/etc/rancher/k3s/k3s.yaml" : open /etc/rancher/k3s/k3s.yaml: permission denied
How should I resolve this? Should I change the permissions of /etc/rancher/k3s/k3s.yaml
/usr/local/bin/in front of "k3s". Which would make that line as this:sudo /usr/local/bin/k3s kubectl config view --raw > "$KUBECONFIG"– UNOPARATOR Aug 01 '22 at 07:30/usr/local/binis not in your$PATHwhich would be pretty awkward anyway. – Evan Carroll Aug 01 '22 at 15:34$PATHbut it might be considered common practice and not mentioned because of that. I'm no linux expert of any kind, just commented in case someone like me encounters the same issue. – UNOPARATOR Aug 02 '22 at 05:06echo $PATHyou should see/usr/local/binin your path. Almost certainly CentOS does that. (also, CentOS is dead, everyone went to Rocky). – Evan Carroll Aug 02 '22 at 14:47export PATH=$PATH:/usr/local/binline to$HOME/.bashrc. (Just checked out Rocky Linux from wiki, might try that next time - thanks for the heads up) – UNOPARATOR Aug 03 '22 at 04:49sudowill use a PATH value different from your own PATH. This other value does not include/usr/local/bin, which is why it couldn't find thek3scommand. One way to resolve this is to add/usr/local/binto thesecure_pathoption in/etc/sudoers. See https://superuser.com/questions/927512/how-to-set-path-for-sudo-commands for details. Ubuntu and Debian do not have this issue (secure_pathincludes/usr/local/bin). – Stanley Yu Dec 28 '23 at 20:55