{"record":{"id":"c10633e777da0047","repo":"kubernetes/kubernetes","slug":"user-is-not-running-as-root","errorCode":null,"errorMessage":"user is not running as root","messagePattern":"user is not running as root","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/kubeadm/app/preflight/checks_unix.go","lineNumber":30,"sourceCode":"Unless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage preflight\n\nimport (\n\t\"os\"\n\n\t\"k8s.io/kubernetes/cmd/kubeadm/app/util/errors\"\n)\n\n// Check validates if an user has elevated (root) privileges.\nfunc (ipuc IsPrivilegedUserCheck) Check() (warnings, errorList []error) {\n\tif os.Getuid() != 0 {\n\t\treturn nil, []error{errors.New(\"user is not running as root\")}\n\t}\n\n\treturn nil, nil\n}\n","sourceCodeStart":12,"sourceCodeEnd":35,"githubUrl":"https://github.com/kubernetes/kubernetes/blob/b882c60b4023bdf09264c2d5d30a2cadebc240fb/cmd/kubeadm/app/preflight/checks_unix.go#L12-L35","documentation":"Returned by IsPrivilegedUserCheck.Check (unix build) when os.Getuid() != 0. kubeadm must run as root on Linux to write /etc/kubernetes, manipulate certs, systemd, and iptables. This is a hard preflight error.","triggerScenarios":"Running 'kubeadm init/join/reset/upgrade' on a non-Linux-Windows platform (the !windows build) as a non-root user (uid != 0).","commonSituations":"Running kubeadm without sudo. SSH'ing as a non-root user and invoking kubeadm directly. Containers/contexts that drop privileges.","solutions":["Run kubeadm with root privileges: prefix with sudo or run as the root user.","If using sudo, ensure the full command and environment are elevated (sudo kubeadm ...).","Avoid su-to-non-root wrappers that reset uid."],"exampleFix":"# before\nkubeadm init ...   # error: user is not running as root\n# after\nsudo kubeadm init ...","handlingStrategy":"validation","validationCode":"if os.Getuid() != 0 {\n    return errors.New(\"kubeadm must run as root; re-run with sudo\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Invoke kubeadm via sudo or as root.","In automation, ensure the runner uid is 0.","Avoid privilege-dropping wrappers around the kubeadm process."],"tags":["kubeadm","preflight","root","privileges","unix"],"analyzedSha":"b882c60b4023bdf09264c2d5d30a2cadebc240fb","analyzedAt":"2026-08-07T04:07:48.144Z","schemaVersion":2},"datasetVersion":"2026-08-07T07:17:06.508Z"}