{"id":13539,"date":"2024-09-04T17:36:01","date_gmt":"2024-09-04T14:36:01","guid":{"rendered":"https:\/\/www.sunucun.com.tr\/blog\/?post_type=dt_articles&#038;p=13539"},"modified":"2026-02-06T01:17:42","modified_gmt":"2026-02-05T22:17:42","slug":"enable-root-user-in-ubuntu","status":"publish","type":"post","link":"https:\/\/sunucun.com.tr\/blog\/enable-root-user-in-ubuntu\/","title":{"rendered":"How to Enable the Root User in Ubuntu"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_80 ez-toc-wrap-center counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav>\n<ul class='ez-toc-list ez-toc-list-level-1 ' >\n<li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/sunucun.com.tr\/blog\/enable-root-user-in-ubuntu\/#1_What_is_the_Root_User_and_Why_is_It_Disabled_by_Default\" >1. What is the Root User and Why is It Disabled by Default?<\/a><\/li>\n<li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/sunucun.com.tr\/blog\/enable-root-user-in-ubuntu\/#2_Advantages_and_Disadvantages_of_Enabling_the_Root_User\" >2. Advantages and Disadvantages of Enabling the Root User<\/a><\/li>\n<li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/sunucun.com.tr\/blog\/enable-root-user-in-ubuntu\/#3_Steps_to_Enable_the_Root_User_on_Ubuntu_2204\" >3. Steps to Enable the Root User on Ubuntu 22.04<\/a>\n<ul class='ez-toc-list-level-4' >\n<li class='ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/sunucun.com.tr\/blog\/enable-root-user-in-ubuntu\/#Step_1_Open_the_Terminal\" >Step 1: Open the Terminal<\/a><\/li>\n<li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/sunucun.com.tr\/blog\/enable-root-user-in-ubuntu\/#Step_2_Set_a_Root_Password\" >Step 2: Set a Root Password<\/a><\/li>\n<li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/sunucun.com.tr\/blog\/enable-root-user-in-ubuntu\/#Step_3_Switch_to_the_Root_User\" >Step 3: Switch to the Root User<\/a><\/li>\n<li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/sunucun.com.tr\/blog\/enable-root-user-in-ubuntu\/#Step_4_Optional_Enable_Root_Login_Over_SSH\" >Step 4: (Optional) Enable Root Login Over SSH<\/a><\/li>\n<\/ul>\n<\/li>\n<li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/sunucun.com.tr\/blog\/enable-root-user-in-ubuntu\/#4_Disabling_the_Root_User\" >4. Disabling the Root User<\/a><\/li>\n<li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/sunucun.com.tr\/blog\/enable-root-user-in-ubuntu\/#5_Security_Considerations\" >5. Security Considerations<\/a><\/li>\n<li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/sunucun.com.tr\/blog\/enable-root-user-in-ubuntu\/#Conclusion\" >Conclusion<\/a><\/li>\n<\/ul>\n<\/nav>\n<\/div>\n<p><a href=\"https:\/\/ubuntu.com\/download\" target=\"_blank\" rel=\"noopener\">Ubuntu<\/a>, as a security-focused Linux distribution, comes with the root account disabled by default. Instead, users are encouraged to use the <code>sudo<\/code> command to perform administrative tasks. However, there are situations where enabling the root user for direct access is necessary or more convenient, especially for advanced users. This guide explains how to enable the root user on Ubuntu 22.04 and provides important considerations for using it securely.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"1_What_is_the_Root_User_and_Why_is_It_Disabled_by_Default\"><\/span><span class=\"ez-toc-section\" id=\"1_What_is_the_Root_User_and_Why_is_It_Disabled_by_Default\"><\/span>1. What is the Root User and Why is It Disabled by Default?<span class=\"ez-toc-section-end\"><\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The root user in Linux is the superuser with unrestricted privileges over the entire system. It can perform any system-wide task, including installing software, managing users, and altering system configurations. However, because of its power, mistakes made while logged in as root can have catastrophic consequences.<\/p>\n<p>For this reason, Ubuntu disables the root account by default, opting for a more secure approach using <code>sudo<\/code>, which allows users to run commands with elevated privileges for a single task. This reduces the risk of accidental system damage and limits the potential impact of a security breach.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"2_Advantages_and_Disadvantages_of_Enabling_the_Root_User\"><\/span><span class=\"ez-toc-section\" id=\"2_Advantages_and_Disadvantages_of_Enabling_the_Root_User\"><\/span>2. Advantages and Disadvantages of Enabling the Root User<span class=\"ez-toc-section-end\"><\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<ul>\n<li><strong>Advantages:<\/strong>\n<ul>\n<li>Full control over the system without needing to prepend commands with <code>sudo<\/code>.<\/li>\n<li>Ideal for system maintenance and troubleshooting where frequent administrative access is needed.<\/li>\n<li>Allows certain advanced tasks that require persistent root access.<\/li>\n<\/ul>\n<\/li>\n<li><strong>Disadvantages:<\/strong>\n<ul>\n<li>Increased security risk: running as root can expose the system to attacks if not used carefully.<\/li>\n<li>Any accidental commands (like deleting important system files) can result in system-wide damage.<\/li>\n<li>Less accountability: commands run as root are not logged the same way <code>sudo<\/code> commands are.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"3_Steps_to_Enable_the_Root_User_on_Ubuntu_2204\"><\/span><span class=\"ez-toc-section\" id=\"3_Steps_to_Enable_the_Root_User_on_Ubuntu_2204\"><\/span>3. Steps to Enable the Root User on Ubuntu 22.04<span class=\"ez-toc-section-end\"><\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<h4><span class=\"ez-toc-section\" id=\"Step_1_Open_the_Terminal\"><\/span><span class=\"ez-toc-section\" id=\"Step_1_Open_the_Terminal\"><\/span>Step 1: Open the Terminal<span class=\"ez-toc-section-end\"><\/span><span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>The first step in enabling the root account is accessing the terminal, where you can run commands.<\/p>\n<ul>\n<li><strong>Shortcut:<\/strong> Press <code>Ctrl + Alt + T<\/code> to open the terminal.<\/li>\n<li><strong>From the menu:<\/strong> Search for &#8220;Terminal&#8221; in the applications menu and open it.<\/li>\n<\/ul>\n<h4><span class=\"ez-toc-section\" id=\"Step_2_Set_a_Root_Password\"><\/span><span class=\"ez-toc-section\" id=\"Step_2_Set_a_Root_Password\"><\/span>Step 2: Set a Root Password<span class=\"ez-toc-section-end\"><\/span><span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>Ubuntu does not set a password for the root account by default. You will need to assign one to activate it.<\/p>\n<p>Run the following command to set the root password:<\/p>\n<pre><code>sudo passwd root<\/code><\/pre>\n<p>You will be prompted to enter a new password for the root user. Make sure to choose a strong password and confirm it by entering it again.<\/p>\n<h4><span class=\"ez-toc-section\" id=\"Step_3_Switch_to_the_Root_User\"><\/span><span class=\"ez-toc-section\" id=\"Step_3_Switch_to_the_Root_User\"><\/span>Step 3: Switch to the Root User<span class=\"ez-toc-section-end\"><\/span><span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>Once you\u2019ve set a password, you can switch to the root user with the following command:<\/p>\n<pre><code>su -<\/code><\/pre>\n<p>After entering the password you set, you will have full root access, indicated by the <code>#<\/code> prompt in the terminal.<\/p>\n<h4><span class=\"ez-toc-section\" id=\"Step_4_Optional_Enable_Root_Login_Over_SSH\"><\/span><span class=\"ez-toc-section\" id=\"Step_4_Optional_Enable_Root_Login_Over_SSH\"><\/span>Step 4: (Optional) Enable Root Login Over SSH<span class=\"ez-toc-section-end\"><\/span><span class=\"ez-toc-section-end\"><\/span><\/h4>\n<p>If you plan to access your server remotely using SSH and want to log in directly as root, you will need to modify the SSH configuration. By default, Ubuntu disables root login via SSH.<\/p>\n<p>To enable SSH root login, follow these steps:<\/p>\n<ol>\n<li>Edit the SSH configuration file:\n<pre><code>sudo nano \/etc\/ssh\/sshd_config<\/code><\/pre>\n<p><img fetchpriority=\"high\" fetchpriority=\"high\" decoding=\"async\" class=\"alignnone wp-image-13532\" src=\"https:\/\/www.sunucun.com.tr\/blog\/wp-content\/uploads\/2024\/09\/Adsiz-tasarim-5-300x162.png\" alt=\"\" width=\"3413\" height=\"1843\" srcset=\"https:\/\/sunucun.com.tr\/blog\/wp-content\/uploads\/2024\/09\/Adsiz-tasarim-5-300x162.png 300w, https:\/\/sunucun.com.tr\/blog\/wp-content\/uploads\/2024\/09\/Adsiz-tasarim-5-1024x553.png 1024w, https:\/\/sunucun.com.tr\/blog\/wp-content\/uploads\/2024\/09\/Adsiz-tasarim-5-768x415.png 768w, https:\/\/sunucun.com.tr\/blog\/wp-content\/uploads\/2024\/09\/Adsiz-tasarim-5-1536x829.png 1536w, https:\/\/sunucun.com.tr\/blog\/wp-content\/uploads\/2024\/09\/Adsiz-tasarim-5-2048x1106.png 2048w\" sizes=\"(max-width: 3413px) 100vw, 3413px\" \/><\/li>\n<li>Find the line that says:\n<pre><code>PermitRootLogin prohibit-password<\/code><\/pre>\n<p>Change it to:<\/p>\n<pre><code>PermitRootLogin yes<\/code><\/pre>\n<p><img decoding=\"async\" class=\"alignnone wp-image-13534\" src=\"https:\/\/www.sunucun.com.tr\/blog\/wp-content\/uploads\/2024\/09\/Adsiz-tasarim-4-300x214.png\" alt=\"\" width=\"3413\" height=\"2439\" srcset=\"https:\/\/sunucun.com.tr\/blog\/wp-content\/uploads\/2024\/09\/Adsiz-tasarim-4-300x214.png 300w, https:\/\/sunucun.com.tr\/blog\/wp-content\/uploads\/2024\/09\/Adsiz-tasarim-4-1024x732.png 1024w, https:\/\/sunucun.com.tr\/blog\/wp-content\/uploads\/2024\/09\/Adsiz-tasarim-4-768x549.png 768w, https:\/\/sunucun.com.tr\/blog\/wp-content\/uploads\/2024\/09\/Adsiz-tasarim-4-1536x1098.png 1536w, https:\/\/sunucun.com.tr\/blog\/wp-content\/uploads\/2024\/09\/Adsiz-tasarim-4-2048x1463.png 2048w\" sizes=\"(max-width: 3413px) 100vw, 3413px\" \/><\/li>\n<li>Save and close the file by pressing <code>CTRL + X<\/code>, then <code>Y<\/code> and <code>Enter<\/code>.<\/li>\n<li>Restart the SSH service:\n<pre><code>sudo systemctl restart ssh<\/code><\/pre>\n<\/li>\n<\/ol>\n<p>You can now log in as root via SSH, but keep in mind that this introduces significant security risks. Use SSH keys for authentication if possible, rather than relying on passwords.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"4_Disabling_the_Root_User\"><\/span><span class=\"ez-toc-section\" id=\"4_Disabling_the_Root_User\"><\/span>4. Disabling the Root User<span class=\"ez-toc-section-end\"><\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>If you decide you no longer want the root account active, you can easily disable it by locking the root password:<\/p>\n<pre><code>sudo passwd -l root<\/code><\/pre>\n<p>This command locks the root account, preventing login. If you also want to disable SSH root access, edit the <code>sshd_config<\/code> file again and change <code>PermitRootLogin<\/code> back to <code>no<\/code>:<\/p>\n<pre><code>PermitRootLogin no<\/code><\/pre>\n<p>Then restart the SSH service:<\/p>\n<pre><code>sudo systemctl restart ssh<\/code><\/pre>\n<h3><span class=\"ez-toc-section\" id=\"5_Security_Considerations\"><\/span><span class=\"ez-toc-section\" id=\"5_Security_Considerations\"><\/span>5. Security Considerations<span class=\"ez-toc-section-end\"><\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Enabling the root account can be useful for <a href=\"https:\/\/sunucun.com.tr\/en\/server-maintenance\" data-internallinksmanager029f6b8e52c=\"160\" title=\"Professional server maintenance services\">system administration<\/a> tasks, but it comes with risks. Here are a few tips to enhance security when using the root account:<\/p>\n<ul>\n<li>Avoid using the root account for daily tasks; only switch to root when necessary.<\/li>\n<li>Always log out of the root account after completing administrative tasks by typing <code>exit<\/code>.<\/li>\n<li>Use SSH keys instead of passwords for secure remote logins, especially if enabling root login over SSH.<\/li>\n<\/ul>\n<h3><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>While enabling the root account in Ubuntu 22.04 provides powerful administrative control, it should be done with caution. The default use of <code>sudo<\/code> is usually sufficient for most tasks, but in some cases, direct root access may be more efficient. By following this guide, you can enable and use the root account safely while understanding the associated risks.<\/p>\n<div class=\"flex max-w-full flex-col flex-grow\">\n<div class=\"min-h-[20px] text-message flex w-full flex-col items-end gap-2 break-words [.text-message+&amp;]:mt-5 overflow-x-auto whitespace-normal\" dir=\"auto\" data-message-author-role=\"assistant\" data-message-id=\"2e975bf0-14b6-4a13-92f4-d811b137f904\">\n<div class=\"flex w-full flex-col gap-1 empty:hidden first:pt-[3px]\">\n<div class=\"markdown prose w-full break-words dark:prose-invert dark\">\n<p>Click <a href=\"https:\/\/sunucun.com.tr\/blog\/enable-root-user-in-ubuntu\/\"><strong>here<\/strong> <\/a>to access more articles about Ubuntu.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"mt-1 flex gap-3 empty:hidden -ml-2\">\n<div class=\"items-center justify-start rounded-xl p-1 flex\">\n<div class=\"flex items-center\"><\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>1. What is the Root User and Why is It Disabled by Default? 2. Advantages and Disadvantages of Enabling the Root User 3. Steps to Enable the Root User on Ubuntu 22.04 Step 1: Open the Terminal Step 2: Set a Root Password Step 3: Switch to the Root User Step 4: (Optional) Enable Root&hellip;<\/p>\n","protected":false},"author":1,"featured_media":13535,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[1519],"tags":[1527],"class_list":["post-13539","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sanal-sunucu","tag-teknoloji"],"_links":{"self":[{"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/posts\/13539","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/comments?post=13539"}],"version-history":[{"count":1,"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/posts\/13539\/revisions"}],"predecessor-version":[{"id":19587,"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/posts\/13539\/revisions\/19587"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/media\/13535"}],"wp:attachment":[{"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/media?parent=13539"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/categories?post=13539"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sunucun.com.tr\/blog\/wp-json\/wp\/v2\/tags?post=13539"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}