{"id":38046,"date":"2022-07-18T09:00:45","date_gmt":"2022-07-18T01:00:45","guid":{"rendered":"https:\/\/www.casbay.com\/guide\/?post_type=kb&#038;p=38046"},"modified":"2022-09-07T20:13:49","modified_gmt":"2022-09-07T12:13:49","slug":"linux-based-vps-sudo-syntax-and-sudoers","status":"publish","type":"kb","link":"https:\/\/www.casbay.com\/guide\/kb\/linux-based-vps-sudo-syntax-and-sudoers","title":{"rendered":"Understanding Linux Based VPS Sudo Syntax And Sudoers File"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"38046\" class=\"elementor elementor-38046\" data-elementor-post-type=\"kb\">\n\t\t\t\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-8d2e2dd elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"8d2e2dd\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-b83f1c8\" data-id=\"b83f1c8\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-c334a70 elementor-widget elementor-widget-text-editor\" data-id=\"c334a70\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>What are sudo commands? On common occasions, most users in a\u00a0<a href=\"https:\/\/www.casbay.com\/vps-hosting-malaysia\" target=\"_blank\" rel=\"noopener\">Linux based VPS<\/a> do not have root access when there are times you need a higher privilege to access within the VPS. Sudo commands allow sudoer, who isn\u2019t a root user, to access a file or system, in the situation when you need to be either a root user or a user with higher privileges. By default, root users don\u2019t need the sudo command.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-2f79fc4 elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"2f79fc4\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-4f43d44\" data-id=\"4f43d44\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-3a202d8 elementor-widget elementor-widget-heading\" data-id=\"3a202d8\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Understanding Sudo<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e822dd2 elementor-widget elementor-widget-text-editor\" data-id=\"e822dd2\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>To understand how sudo works, access your VPS server with SSH as a non-root user. As a non-root user, you won\u2019t be able to add users to the Linux VPS usually. However, this can be allowed using the sudo command such as the one shown in the command line below.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-dae7b8f elementor-widget elementor-widget-text-editor\" data-id=\"dae7b8f\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<pre>sudo useradd &lt;username&gt;<\/pre>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e6728fa elementor-widget elementor-widget-text-editor\" data-id=\"e6728fa\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>Replace \u201c&lt;username&gt;\u201d with the user\u2019s name of your preference. This is how non-root users are able to get higher privileges in a Linux VPS. A permission denied output will be revealed to users who don\u2019t use the sudo command without root access.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-90fde2d elementor-section-boxed elementor-section-height-default elementor-section-height-default\" data-id=\"90fde2d\" data-element_type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-703cd88\" data-id=\"703cd88\" data-element_type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t\t\t<div class=\"elementor-element elementor-element-5972892 elementor-widget elementor-widget-heading\" data-id=\"5972892\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Sudoers File Syntax<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-742baa5 elementor-widget elementor-widget-text-editor\" data-id=\"742baa5\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>The sudoers file is located at the directory \u201c\/etc\/sudoers\u201d. To open the file, use any text editor of your preference. The following command uses the nano text editor to open the sudoers file.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-f741a90 elementor-widget elementor-widget-text-editor\" data-id=\"f741a90\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<pre>nano \/etc\/sudoers<\/pre>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-a0052cc elementor-widget elementor-widget-text-editor\" data-id=\"a0052cc\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>In the text file, you should be able to see the users\u2019 privileges specifications. The following line will explain what does the line means and how to understand them. There should be a line similar to the following.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e005e43 elementor-widget elementor-widget-text-editor\" data-id=\"e005e43\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<pre>root ALL=(ALL:ALL) ALL\n%admin ALL=(ALL) ALL\n%sudo ALL=(ALL:ALL) ALL<\/pre>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-b0e067b elementor-widget elementor-widget-text-editor\" data-id=\"b0e067b\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t\t\t<p>The following shows that all root users, admins, and sudoers have all privileges to run any command on the system. To break down what it means, For the \u201c%\u201d symbol in front of admin and sudo specifies the group of users in the respective category.<\/p><p>We will break \u201croot ALL= (ALL:ALL) ALL\u201d into a total of 5 fields.<\/p><ul><li><strong>root<\/strong> &#8211; The 1st field of the syntax and it indicates the user type which the rule later will apply to it.<\/li><li><strong>1st &#8220;ALL&#8221;\u00a0<\/strong>&#8211; The 2nd field of the syntax and it indicates the rules apply to all of the hosts.<\/li><li><strong>2nd &#8220;ALL&#8221;\u00a0<\/strong>&#8211; The 3rd field of the syntax and it indicates the host can run commands as all users.<\/li><li><strong>3rd &#8220;ALL&#8221;\u00a0<\/strong>&#8211; The 4th field of the syntax and it indicates the host can run commands as all the groups.<\/li><li><strong>4th &#8220;ALL&#8221;<\/strong> &#8211; The 5th field of the syntax and it indicates the rules apply to all commands.<\/li><\/ul>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>What are sudo commands? On common occasions, most users in a\u00a0Linux based VPS do not have root access when there are times you need a higher privilege to access within the VPS. Sudo commands allow sudoer, who isn\u2019t a root user, to access a file or system, in the situation when you need to be [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":38048,"comment_status":"closed","ping_status":"closed","template":"","meta":{"site-sidebar-layout":"no-sidebar","site-content-layout":"page-builder","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"disabled","ast-breadcrumbs-content":"","ast-featured-img":"disabled","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"default","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}}},"kbtopic":[109],"kbtag":[106,105],"mkb_version":[],"_links":{"self":[{"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kb\/38046"}],"collection":[{"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kb"}],"about":[{"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/types\/kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/comments?post=38046"}],"version-history":[{"count":9,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kb\/38046\/revisions"}],"predecessor-version":[{"id":38096,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kb\/38046\/revisions\/38096"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/media\/38048"}],"wp:attachment":[{"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/media?parent=38046"}],"wp:term":[{"taxonomy":"kbtopic","embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kbtopic?post=38046"},{"taxonomy":"kbtag","embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kbtag?post=38046"},{"taxonomy":"mkb_version","embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/mkb_version?post=38046"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}