{"id":14634,"date":"2024-10-07T19:11:51","date_gmt":"2024-10-07T19:11:51","guid":{"rendered":"https:\/\/truehost.com\/support\/?post_type=docs&#038;p=14634"},"modified":"2024-10-08T08:33:38","modified_gmt":"2024-10-08T08:33:38","password":"","slug":"how-to-create-a-sudo-user-on-your-server","status":"publish","type":"docs","link":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-create-a-sudo-user-on-your-server\/","title":{"rendered":"How to create a sudo user on your server"},"content":{"rendered":"\n<p>Creating a <strong>sudo user<\/strong> on your server allows you to manage administrative tasks securely without needing to use the root account directly. A <strong>sudo<\/strong> user has permission to execute commands with root privileges, which adds a layer of security to your system.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Requirements<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Root SSH access to the server.<\/li>\n<\/ul>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Step 1: Log in to Your Server<\/strong> &#8211; <\/h5>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Log in to the server via SSH using <strong><a href=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-access-a-server-via-ssh-terminal\/\" target=\"_blank\" rel=\"noreferrer noopener\">these steps<\/a><\/strong><\/li>\n<\/ul>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Step 2: Create a New User<\/strong><\/h5>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Once logged in, create a new user by running the following command. Replace <code>newuser<\/code> with the desired username. This command creates a new user and its home directory.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>adduser newuser<\/strong><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Replace <code>newuser<\/code> with the desired username. This command creates a new user and its home directory. In the image below, we are creating a user called <strong>tke<\/strong><\/li>\n\n\n\n<li>You may be asked to input user details as in the image  below. Youn can put them or just hit <strong>Enter<\/strong> key to proceed<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"453\" height=\"362\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-158.png\" alt=\"\" class=\"wp-image-14649\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-158.png 453w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-158-300x240.png 300w\" sizes=\"auto, (max-width: 453px) 100vw, 453px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Now, set a password for the newly created user using the command below, again replacing new user with the name of your actual user that you just created<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>passwd newuser<\/strong><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You will be prompted to enter and confirm a password.<\/li>\n<\/ul>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Step 3: Add the User to the Sudo Group<\/strong><\/h5>\n\n\n\n<ul class=\"wp-block-list\">\n<li>To grant the new user sudo privileges, add the user to the <strong>sudo <\/strong>or<strong> wheel <\/strong>group based on your OS destribution. <\/li>\n\n\n\n<li>On most Linux distributions, users in this groups are allowed to use <code>sudo<\/code> to run commands with root privileges.<\/li>\n\n\n\n<li>On <strong>Ubuntu, Linux Mint, Debian<\/strong> and other Debian-based OSes, use the command below to add your user to <strong>sudo<\/strong> group.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>usermod -aG sudo newuser<\/strong><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>For <strong>CentOS<\/strong>, <strong>Almalinux<\/strong> or <strong>RedHat<\/strong> systems, use the <strong>wheel<\/strong> group instead:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>usermod -aG wheel newuser<\/strong><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The <code>-aG<\/code> option adds the user to the specified group (<code>sudo<\/code> in this case) without removing it from other groups.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"659\" height=\"304\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-159.png\" alt=\"\" class=\"wp-image-14651\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-159.png 659w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-159-300x138.png 300w\" sizes=\"auto, (max-width: 659px) 100vw, 659px\" \/><\/figure>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Step 4: Verify Sudo Access<\/strong><\/h5>\n\n\n\n<ul class=\"wp-block-list\">\n<li>To verify that the new user has sudo privileges, log out from the root account:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>exit<\/strong><\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Log in again using the newly created user:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh newuser@your_server_ip<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Test sudo privileges by running a simple command such as the one below<\/li>\n\n\n\n<li>When you runt he command, you\u2019ll be prompted for the new user\u2019s password. <\/li>\n\n\n\n<li>If everything is set up correctly, the command will return <code>root<\/code>, indicating that the user has sudo privileges. See the highlights in the image below;<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo whoami<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"700\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-160-1024x700.png\" alt=\"\" class=\"wp-image-14653\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-160-1024x700.png 1024w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-160-300x205.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-160-768x525.png 768w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-160.png 1054w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Step 5: Optional &#8211; Customize Sudo Privileges<\/strong><\/h5>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You can do other optional tweaks on the server as you desire. These are optional and you should only dot hem if you with. See the important links section below<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Important Links<\/strong><\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong><a href=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-disable-root-ssh-completely\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to disable root ssh completely<\/a><\/strong><\/li>\n\n\n\n<li><strong><a href=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-disable-root-ssh-with-password-but-enable-via-ssh-keys\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to disable root ssh with password but enable via ssh keys<\/a><\/strong><\/li>\n\n\n\n<li><strong><a href=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-change-ssh-port-to-a-custom-port\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to change SSH port to a custom port<\/a><\/strong><\/li>\n\n\n\n<li><strong><a href=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-prevent-password-request-when-running-sudo-commands\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to prevent password request when running sudo commands<\/a><\/strong><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Creating a sudo user on your server allows you to manage administrative tasks securely without needing to use the root account directly. A sudo user has permission to execute commands with root privileges, which adds a layer of security to your system. Requirements Step 1: Log in to Your Server &#8211; Step 2: Create a [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"_eb_attr":"","_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"doc_category":[1820,1824,1879,2128],"doc_tag":[],"class_list":["post-14634","docs","type-docs","status-publish","hentry","doc_category-cloud-servers-in-kenya","doc_category-dedicated-servers","doc_category-servers","doc_category-vps-servers"],"year_month":"2026-07","word_count":461,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"Eugene","author_nicename":"eugene","author_url":"https:\/\/truehost.com\/support\/author\/eugene\/"},"doc_category_info":[{"term_name":"Cloud servers in Kenya","term_url":"https:\/\/truehost.com\/support\/docs-category\/cloud-servers-in-kenya\/"},{"term_name":"dedicated servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/dedicated-servers\/"},{"term_name":"Servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/servers\/"},{"term_name":"VPS-Servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/vps-servers\/"}],"doc_tag_info":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to create a sudo user on your server -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-create-a-sudo-user-on-your-server\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to create a sudo user on your server -\" \/>\n<meta property=\"og:description\" content=\"Creating a sudo user on your server allows you to manage administrative tasks securely without needing to use the root account directly. A sudo user has permission to execute commands with root privileges, which adds a layer of security to your system. Requirements Step 1: Log in to Your Server &#8211; Step 2: Create a [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-create-a-sudo-user-on-your-server\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-10-08T08:33:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-158.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-create-a-sudo-user-on-your-server\\\/\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-create-a-sudo-user-on-your-server\\\/\",\"name\":\"How to create a sudo user on your server -\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-create-a-sudo-user-on-your-server\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-create-a-sudo-user-on-your-server\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2024\\\/10\\\/image-158.png\",\"datePublished\":\"2024-10-07T19:11:51+00:00\",\"dateModified\":\"2024-10-08T08:33:38+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-create-a-sudo-user-on-your-server\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-create-a-sudo-user-on-your-server\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-create-a-sudo-user-on-your-server\\\/#primaryimage\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2024\\\/10\\\/image-158.png\",\"contentUrl\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2024\\\/10\\\/image-158.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-create-a-sudo-user-on-your-server\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/truehost.com\\\/support\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to create a sudo user on your server\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#website\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/\",\"name\":\"\",\"description\":\"Help In a Click\",\"publisher\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/truehost.com\\\/support\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#organization\",\"name\":\"Truehost Kenya\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/cropped-image_2026-04-16_174808866.png\",\"contentUrl\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/cropped-image_2026-04-16_174808866.png\",\"width\":240,\"height\":48,\"caption\":\"Truehost Kenya\"},\"image\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to create a sudo user on your server -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-create-a-sudo-user-on-your-server\/","og_locale":"en_US","og_type":"article","og_title":"How to create a sudo user on your server -","og_description":"Creating a sudo user on your server allows you to manage administrative tasks securely without needing to use the root account directly. A sudo user has permission to execute commands with root privileges, which adds a layer of security to your system. Requirements Step 1: Log in to Your Server &#8211; Step 2: Create a [&hellip;]","og_url":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-create-a-sudo-user-on-your-server\/","article_modified_time":"2024-10-08T08:33:38+00:00","og_image":[{"url":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-158.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-create-a-sudo-user-on-your-server\/","url":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-create-a-sudo-user-on-your-server\/","name":"How to create a sudo user on your server -","isPartOf":{"@id":"https:\/\/truehost.com\/support\/#website"},"primaryImageOfPage":{"@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-create-a-sudo-user-on-your-server\/#primaryimage"},"image":{"@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-create-a-sudo-user-on-your-server\/#primaryimage"},"thumbnailUrl":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-158.png","datePublished":"2024-10-07T19:11:51+00:00","dateModified":"2024-10-08T08:33:38+00:00","breadcrumb":{"@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-create-a-sudo-user-on-your-server\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/truehost.com\/support\/knowledge-base\/how-to-create-a-sudo-user-on-your-server\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-create-a-sudo-user-on-your-server\/#primaryimage","url":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-158.png","contentUrl":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-158.png"},{"@type":"BreadcrumbList","@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-create-a-sudo-user-on-your-server\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/truehost.com\/support\/"},{"@type":"ListItem","position":2,"name":"How to create a sudo user on your server"}]},{"@type":"WebSite","@id":"https:\/\/truehost.com\/support\/#website","url":"https:\/\/truehost.com\/support\/","name":"","description":"Help In a Click","publisher":{"@id":"https:\/\/truehost.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/truehost.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/truehost.com\/support\/#organization","name":"Truehost Kenya","url":"https:\/\/truehost.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/truehost.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2026\/04\/cropped-image_2026-04-16_174808866.png","contentUrl":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2026\/04\/cropped-image_2026-04-16_174808866.png","width":240,"height":48,"caption":"Truehost Kenya"},"image":{"@id":"https:\/\/truehost.com\/support\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/14634","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/comments?post=14634"}],"version-history":[{"count":6,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/14634\/revisions"}],"predecessor-version":[{"id":14660,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/14634\/revisions\/14660"}],"wp:attachment":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/media?parent=14634"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/doc_category?post=14634"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/doc_tag?post=14634"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}