---
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-20
published: true
tags:
  - homelab
  - k3s
  - thought
template: link
---


<div class="embed-card embed-card-external embed-card-provider-reddit">
  <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">Can I access k3s using just kubectl (no sudo and no k3s command)</div>
      <div class="embed-card-description">Can I access k3s using just kubectl (no sudo and no k3s command)</div>
      <div class="embed-card-meta">Reddit &middot; 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
```

!!! note

    This post is a <a href="/thoughts/" class="wikilink" data-title="Thoughts" data-description="These are generally my thoughts on a web page or some sort of url, except a rare few don&#39;t have a link. These are dual published off of my..." data-date="2024-04-01">thought</a>. It's a short note that I make
    about someone else's content online <a href="/tags/thoughts/" class="hashtag-tag" data-tag="thoughts" data-count=2 data-reading-time=3 data-reading-time-text="3 minutes">#thoughts</a>
