---
title: "Can I access k3s using just kubectl (no sudo and no k3s comman..."
description: "!https://www.reddit.com/r/kubernetes/comments/cojjf5/can_access_using_kubectl_sudo_and/"
date: 2023-10-21
published: true
tags:
  - containers
  - homelab
  - k3s
  - kubernetes
  - thought
template: link
---


<div class="embed-card embed-card-external">
  <a href="https://www.reddit.com/r/kubernetes/comments/cojjf5/can_i_access_k3s_using_just_kubectl_no_sudo_and/" class="embed-card-link" target="_blank" rel="noopener noreferrer">
    <div class="embed-card-content">
      <div class="embed-card-title">Reddit - Please wait for verification</div>
      <div class="embed-card-meta">reddit.com</div>
    </div>
  </a>
</div>


Right after installing k3s you are going to need to use `sudo` to use any `kubectl` command.  The reason for this is that the default config is owned by root.  To get around this you will need to make your own config and set the `KUBECONFIG` environment variable

To do this I used `sudo` one last time to copy the `k3s.yaml` file into my own directory and take ownership of it.

``` bash
sudo cp /etc/rancher/k3s/k3s.yaml /home/waylon/.config/kube

sudo chown -R waylon:waylon ~/.config/kube

export KUBECONFIG=~/.config/kube/k3s.yaml
```
