{"id":3761,"date":"2023-11-21T16:04:37","date_gmt":"2023-11-21T08:04:37","guid":{"rendered":"https:\/\/www.servergigabit.com\/guide\/?post_type=kb&#038;p=3761"},"modified":"2026-03-16T11:52:16","modified_gmt":"2026-03-16T03:52:16","slug":"superuser-accounts-linux-tips","status":"publish","type":"kb","link":"https:\/\/www.servergigabit.com\/guide\/kb\/superuser-accounts-linux-tips","title":{"rendered":"Superuser Accounts in Linux: 7 Essential Tips for Beginners"},"content":{"rendered":"<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone wp-image-3762\" src=\"https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/n-300x169.jpeg\" alt=\"Superuser Accounts\" width=\"705\" height=\"397\" srcset=\"https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/n-300x169.jpeg 300w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/n-1024x576.jpeg 1024w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/n-768x432.jpeg 768w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/n-1536x864.jpeg 1536w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/n-2048x1152.jpeg 2048w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/n-370x208.jpeg 370w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/n-1230x692.jpeg 1230w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/n-800x450.jpeg 800w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/n-390x219.jpeg 390w\" sizes=\"(max-width: 705px) 100vw, 705px\" \/><\/p>\n<p data-sourcepos=\"7:1-7:4\">This guide is designed to provide a comprehensive overview of superuser accounts, sudo, and root in Linux. It is intended for beginners who are new to <a href=\"https:\/\/www.servergigabit.com\/linux-vps-hosting\/\">Linux<\/a> and want to understand the basics of user management.<\/p>\n<h2 data-sourcepos=\"9:1-9:50\"><strong>The Root User, Regular Users, and System Users<\/strong><\/h2>\n<p data-sourcepos=\"11:1-11:45\">In Linux, there are three main types of users: the root user, system users, and regular users.<\/p>\n<ul data-sourcepos=\"13:1-13:77\">\n<li data-sourcepos=\"13:1-13:77\">\n<p data-sourcepos=\"13:3-13:203\"><strong>Root User:<\/strong> The root user is the most powerful user in Linux. It has the ability to perform any action on the system, including creating and deleting users, modifying files, and installing software.<\/p>\n<\/li>\n<li data-sourcepos=\"15:1-16:0\">\n<p data-sourcepos=\"15:3-15:155\"><strong>System Users:<\/strong> System users are created by the operating system and are used to run background processes. These users cannot be logged in to directly.<\/p>\n<\/li>\n<li data-sourcepos=\"17:1-18:0\">\n<p data-sourcepos=\"17:3-17:170\"><strong>Regular Users:<\/strong> Regular users are the typical users of a <a href=\"https:\/\/www.servergigabit.com\/linux-vps-hosting\/\">Linux system<\/a>. They have limited privileges and can only perform actions that are explicitly allowed to them.<\/p>\n<\/li>\n<\/ul>\n<h2 data-sourcepos=\"17:1-17:43\"><strong>Checking if You Are Logged in as a Root<\/strong><\/h2>\n<p data-sourcepos=\"19:1-19:180\">To check if you are logged in as a root, look at the command prompt. The first word before the &#8216;@&#8217; sign is the name of your user. If it is &#8216;root&#8217;, then you are logged in as a root.<br \/>\n<img decoding=\"async\" src=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2022\/03\/root-CLI-prompt.png\" alt=\"Logged in as \" \/><\/p>\n<h2 data-sourcepos=\"21:1-21:40\"><strong>Printing the Current User&#8217;s Username<\/strong><\/h2>\n<p data-sourcepos=\"23:1-23:64\">To print the current user&#8217;s username, use the following command:<\/p>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container no-decoration-radius\" role=\"text\">whoami\r\n<\/code><\/pre>\n<\/div>\n<h2 data-sourcepos=\"29:1-29:25\"><strong>Central User Database<\/strong><\/h2>\n<p data-sourcepos=\"31:1-31:40\">Linux stores information about all users in a file named &#8216;\/etc\/passwd&#8217;. The &#8216;cat&#8217; command can be used to browse this file.<br \/>\n<img decoding=\"async\" src=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2022\/03\/passwd-file.png\" alt=\"\/etc\/passwd file\" \/><\/p>\n<h2 data-sourcepos=\"33:1-33:40\"><strong>Understanding the &#8216;\/etc\/passwd&#8217; File<\/strong><\/h2>\n<p data-sourcepos=\"35:1-35:136\">The &#8216;\/etc\/passwd&#8217; file contains a list of users, with each user&#8217;s information on a separate line. The format of each line is as follows:<\/p>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container no-decoration-radius\" role=\"text\">username:x:user_id:group_id:user_info:home_directory:shell\r\n<\/code><\/pre>\n<\/div>\n<p data-sourcepos=\"41:1-41:185\">The third column of each line contains the user&#8217;s ID. The user ID for root is 0. Values 1 to 500 are reserved for system users. Values starting from 1000 are reserved for regular users.<\/p>\n<h2 data-sourcepos=\"43:1-43:24\"><strong>Becoming a Superuser<\/strong><\/h2>\n<p data-sourcepos=\"45:1-45:131\">To become a superuser, you must log in as root. However, you can also elevate your privileges temporarily using the &#8216;sudo&#8217; command.<\/p>\n<h2 data-sourcepos=\"47:1-47:14\"><strong>Using sudo<\/strong><\/h2>\n<p data-sourcepos=\"49:1-49:158\">To use sudo, simply type &#8216;sudo&#8217; before the command that requires superuser privileges. For example, to update the system, you would use the following command:<\/p>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container no-decoration-radius\" role=\"text\">sudo apt-get update\r\n<\/code><\/pre>\n<\/div>\n<h2 data-sourcepos=\"55:1-55:50\"><strong>Gaining Superuser Rights for the Whole Session<\/strong><\/h2>\n<p data-sourcepos=\"57:1-57:65\">To gain superuser rights for the whole session, use the following command:<\/p>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container no-decoration-radius\" role=\"text\">sudo -i\r\n<\/code><\/pre>\n<\/div>\n<p data-sourcepos=\"63:1-63:135\"><img decoding=\"async\" src=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2022\/03\/Tom-to-root.png\" alt=\"Tom to elevate the rights to root\" \/><br \/>\nThis will change your command prompt to reflect that you are now a superuser. To check your current user ID, use the following command:<\/p>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container no-decoration-radius\" role=\"text\">id\r\n<\/code><\/pre>\n<\/div>\n<h2 data-sourcepos=\"69:1-69:29\"><img decoding=\"async\" src=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2022\/03\/ID-from-Tom-to-root-1.png\" alt=\"ID for regular users and root\" \/><\/h2>\n<h2 data-sourcepos=\"69:1-69:29\"><strong>Managing Sudo Permissions<\/strong><\/h2>\n<p data-sourcepos=\"71:1-71:104\"><img decoding=\"async\" src=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2022\/03\/Cordelia-sudo-denied.png\" alt=\"Sudo is denied\" \/><br \/>\nNot every user is allowed to use sudo. To give a user permission to use sudo, use the following command:<\/p>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container no-decoration-radius\" role=\"text\">sudo usermod -aG sudo Cordelia\r\n<\/code><\/pre>\n<\/div>\n<p data-sourcepos=\"77:1-77:69\">To remove a user&#8217;s permission to use sudo, use the following command:<\/p>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container no-decoration-radius\" role=\"text\">sudo gpasswd -d Cordelia sudo\r\n<\/code><\/pre>\n<\/div>\n<h2 data-sourcepos=\"83:1-83:14\"><strong>Conclusion<\/strong><\/h2>\n<p data-sourcepos=\"85:1-85:219\"><span class=\"animating\">This guide has provided an overview of user rights in <a href=\"https:\/\/www.linux.org\/\" target=\"_blank\" rel=\"noopener\">Linux<\/a>,<\/span><span class=\"animating\"> with a focus on the root user,<\/span><span class=\"animating\"> regular users,<\/span><span class=\"animating\"> and system users.<\/span><span class=\"animating\"> It has also explained how to become a superuser using sudo and how to manage sudo permissions.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This guide is designed to provide a comprehensive overview of superuser accounts, sudo, and root in Linux. It is intended for beginners who are new to Linux and want to understand the basics of user management. The Root User, Regular Users, and System Users In Linux, there are three main types of users: the root user, system users, and regular&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"kbtopic":[1099],"kbtag":[1178,1177,1176],"class_list":["post-3761","kb","type-kb","status-publish","hentry","kbtopic-tutorials","kbtag-root","kbtag-sudo","kbtag-superuser-accounts"],"_links":{"self":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb\/3761","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb"}],"about":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/types\/kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/comments?post=3761"}],"version-history":[{"count":4,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb\/3761\/revisions"}],"predecessor-version":[{"id":6288,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb\/3761\/revisions\/6288"}],"wp:attachment":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/media?parent=3761"}],"wp:term":[{"taxonomy":"kbtopic","embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kbtopic?post=3761"},{"taxonomy":"kbtag","embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kbtag?post=3761"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}