# Where does microk8s store kubectl config file?

**URL:** <https://discuss.kubernetes.io/t/where-does-microk8s-store-kubectl-config-file/11032>\
**Category:** microk8s\
**Created:** [May 20, 2020, 8:55pm UTC](https://discuss.kubernetes.io/t/where-does-microk8s-store-kubectl-config-file/11032 "2020-05-20T20:55:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TristanStanic](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/tristanstanic/32/5148_2.png) [@TristanStanic](https://discuss.kubernetes.io/u/TristanStanic)\
**Post date:** [May 20, 2020, 8:55pm UTC](https://discuss.kubernetes.io/t/where-does-microk8s-store-kubectl-config-file/11032/1 "2020-05-20T20:55:00Z")

</div>

Using microk8s 1.18 on Ubuntu 20.04

Kubernetes documentation on [kubectl config](https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#config) states that the default location of the kubectl config file is `${HOME}/.kube/config`

I can see the config by `microk8s.kubectl config view`. However, there is no file `~/.kube/config`. Where is the location of that config file?

---

<div class="post-metadata">

**Author:** ![kjackal](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/kjackal/32/1750_2.png) [@kjackal](https://discuss.kubernetes.io/u/kjackal)\
**Post date:** [May 21, 2020, 7:00am UTC](https://discuss.kubernetes.io/t/where-does-microk8s-store-kubectl-config-file/11032/2 "2020-05-21T07:00:45Z")

</div>

You can extract the kubeconfig file with the `microk8s config` command.

The actual kubeconfig file is at `/var/snap/microk8s/current/credentials/client.config`

To change the kubeconfig file used by `microk8s.kubectl` you can edit `/var/snap/microk8s/current/args/kubectl-env`

---

<div class="post-metadata">

**Author:** ![Uvindu\_Sahan](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.kubernetes.io/uvindu_sahan/32/14012_2.png) [@Uvindu\_Sahan](https://discuss.kubernetes.io/u/Uvindu_Sahan)\
**Post date:** [October 24, 2024, 6:14am UTC](https://discuss.kubernetes.io/t/where-does-microk8s-store-kubectl-config-file/11032/4 "2024-10-24T06:14:26Z")

</div>

Can you tell me how to recreate kubeconfig file and disable access from old file
