How To Become Root In Ubuntu: 10 Steps (with Pictures) - WikiHow

Skip to ContentQuizzes
  • Home
  • Random
  • Browse Articles
  • Quizzes & Games
  • All QuizzesHot
  • Love Quizzes
  • Personality Quizzes
  • Fun Games
  • Dating Simulator
  • Learn Something New
  • Forums
  • Courses
  • Happiness Hub
  • Explore More
  • Support wikiHow
  • About wikiHow
  • Log in / Sign up
Terms of Use wikiHow is where trusted research and expert knowledge come together. Learn why people trust wikiHow How to Get Root Access in Ubuntu Linux PDF download Download Article Run commands with root access or enable root logins with ease Written by Nicole Levine, MFA

Last Updated: December 14, 2025 Fact Checked

PDF download Download Article
  • Use Sudo to Run Commands
  • |
  • Enable & Log In as Root
  • |
  • Root Login at the Login Screen
  • |
  • Root Login via SSH
  • |
  • Video
  • |
  • Q&A
  • |
  • Tips
|Show more |Show less X

This article was co-authored by wikiHow staff writer, Nicole Levine, MFA. Nicole Levine is a Technology Writer and Editor for wikiHow. She has more than 20 years of experience creating technical documentation and leading support teams at major web hosting and software companies. Nicole also holds an MFA in Creative Writing from Portland State University and teaches composition, fiction-writing, and zine-making at various institutions. There are 7 references cited in this article, which can be found at the bottom of the page. This article has been fact-checked, ensuring the accuracy of any cited facts and confirming the authority of its sources. This article has been viewed 1,232,053 times. Learn more...

To run administrative tasks in Linux, you must have root (also known as superuser) access. While having a separate root account is common in most Linux distributions, Ubuntu disables root logins by default. To run commands with root permissions, it's best to use sudo. However, if you must log in as root or get a root shell, it's easy to enable the root account. This guide will teach you multiple ways to become root in Ubuntu Linux.

Becoming Root in Ubuntu: Quick Options

  • To run a command as root, type sudo before the rest of the command (e.g., sudo vim /etc/httpd.conf).
  • To enable the root user, use sudo passwd rt to create a root account and passwd.
  • To access a root shell after enabling root, use su -.

Steps

Method 1 Method 1 of 4:

Running Root Commands with Sudo

PDF download Download Article
  1. Step 1 Press Ctrl+Alt+T to... 1 Press Ctrl+Alt+T to open a terminal window.[1] Because Ubuntu locks the root account by default, you cannot use su to become root as you would in other Linux distributions.[2] Instead, start your commands with sudo.
    • If you want to enable the root user in Ubuntu so you can log in as root, see Enabling the Root User. We don't recommend doing this for security reasons, but it is possible.
  2. Step 2 Type sudo before the rest of your command. 2 Type sudo before the rest of your command. “Sudo” stands for “substitute user do.” When you add sudo to the beginning of a command, the command will run as root.
    • For example: sudo /etc/init.d/networking stop stops the network service, and sudo adduser adds a new user to the system. Both of these tasks require root access.
    • You will be prompted to enter your password before sudo runs the command. Linux stores your password for 15 minutes, so you won’t have to keep typing it.
    Advertisement
  3. Step 3 Use sudo -H before running a command that opens a program with a Graphical User Interface (GUI). 3 Use sudo -H before running a command that opens a program with a Graphical User Interface (GUI). For security reasons, Ubuntu does not recommend using “sudo” to open programs with GUIs.[3] However, this should work for most programs if you absolutely must.
    • The gksudo command is now deprecated in Ubuntu.
  4. Step 4 Give sudo access to another user. 4 Give sudo access to another user. If you are setting up an account for someone who does not currently have root access, you will need to add their username to the sudo group. To do this, type usermod -aG sudo username (but replace “username” with the correct username).
  5. Advertisement
Method 2 Method 2 of 4:

Enabling Root Login

PDF download Download Article
  1. Step 1 Press Ctrl+Alt+T to open a terminal window. 1 Press Ctrl+Alt+T to open a terminal window. For security purposes (and to avoid damage), the root user account is locked by default in Ubuntu. If you must have a root login (if a program your business uses requires it, or this workstation will only be used by a single user), you can enable the root user with some simple commands.[4]
    • Enabling the root user can put your system at risk and is not recommended by Ubuntu.[5]
  2. Step 2 Type sudo passwd root and press ↵ Enter. 2 Type sudo passwd root and press Enter. You will be prompted to set a new password for the root user. Don’t lose this password.
  3. Step 3 Enter a password, then press ↵ Enter. 3 Enter a password, then press Enter.
  4. Step 4 Retype the password when prompted, then press ↵ Enter. 4 Retype the password when prompted, then press Enter. The root user should now have a password.
  5. Step 5 Type su - and press ↵ Enter. 5 Type su - and press Enter. Enter the root password when prompted to arrive at the root prompt.
    • To disable the root account, type sudo passwd -l root.[6]
  6. Advertisement
Method 3 Method 3 of 4:

Enabling Root Login in at the Ubuntu Login Screen

PDF download Download Article
  1. Step 1 Press Ctrl+Alt+T to open a terminal window. 1 Press Ctrl+Alt+T to open a terminal window. If you've enabled the root user, you won't be able to log in to the Ubuntu GUI as root unless you enable root GUI login. We really don't recommend doing this, but it is possible.[7]
    • If you haven't enabled the root user yet, use this method to do so.
  2. Step 2 Use su - to become root. 2 Use su - to become root. As long as you've enabled the root user, this will give you a root shell. When prompted for a password, enter the root password you've set for Ubuntu.
  3. Step 3 Open /etc/gdm3/custom.conf in a text editor. 3 Open /etc/gdm3/custom.conf in a text editor. Use sudo to run the command. For example, if you use vim as your text editor, use sudo vim /etc/gdm3/custom.conf.
  4. Step 4 Add a new entry. 4 Add a new entry. Here's what you'll need to add:
    • Under "TimedLogInDelay = 10", open a new line.
    • Type AllowRoot=True.
    • Save your changes and close the file.
  5. Step 5 Edit /etc/pam.d/gdm-password for editing. 5 Edit /etc/pam.d/gdm-password for editing. Again, use sudo, e.g., sudo vim /etc/pam.d/gdm-password if you prefer vim.
  6. Step 6 Comment out the line "auth required pam_succeed_If." 6 Comment out the line "auth required pam_succeed_If." To do this, enter a hash symbol (#) before the line: # auth required pam_succeed_If.[8]
    • When you're finished, save and close the file.
    • To log in as root on the login screen, select Not Listed from the login menu, then type root as the user. Enter the root password to log in.
    • To disable root login at the GUI login screen, simply delete the line you added to /etc/gdm3/custom.conf and uncomment the line you commented in etc/pam.d/gdm-password.
  7. Advertisement
Method 4 Method 4 of 4:

Enabling Root Login via SSH in Ubuntu

PDF download Download Article
  1. Step 1 Open /etc/ssh/sshd_config in any text editor. 1 Open /etc/ssh/sshd_config in any text editor. You'll need root access to edit this file, so open it using sudo. For example, if you want to open it in vim, use sudo vim /etc/ssh/sshd_config.[9]
    • If you haven't enabled the root user yet, use this method to do so.
  2. Step 2 Uncomment the PermitRootLogin line. 2 Uncomment the PermitRootLogin line. The line you're looking for is #PermitRootLogin prohibit-password. To uncomment, just remove the hashmark at the beginning.
  3. Step 3 Replace prohibit-password with yes. 3 Replace prohibit-password with yes. The line should now look like PermitRootLogin yes.[10]
  4. Step 4 Restart sshd. 4 Restart sshd. To do this, use sudo systemctl restart ssh. This allows the root user to log in via SSH.
    • To reverse this, just comment out the line again.
  5. Advertisement

Community Q&A

Search Add New Question
  • Question I read the article and tried gksudo on Ubuntu, but it doesn't work. I learned that it is abolished by most flavors of Linux. What do I do? Thomas J. Jordan Sr. Thomas J. Jordan Sr. Community Answer gksudo won't work in a Wayland session; switch to an Xorg session and try. Thanks! We're glad this was helpful. Thank you for your feedback. If wikiHow has helped you, please consider a small contribution to support us in helping more readers like you. We’re committed to providing the world with free how-to resources, and even $1 helps us in our mission. Support wikiHow Yes No Not Helpful 13 Helpful 24
  • Question How to administer password created by command? Jisjo Jisjo Community Answer You can create a root password by command line. In Linux root has Administrator like the Windows Operating system. Use this below command to set root password: $ sudo passwd root. Thanks! We're glad this was helpful. Thank you for your feedback. If wikiHow has helped you, please consider a small contribution to support us in helping more readers like you. We’re committed to providing the world with free how-to resources, and even $1 helps us in our mission. Support wikiHow Yes No Not Helpful 6 Helpful 7
  • Question i did the steps for enabling and setting password for root but after typing: " sudo - " it still says su: Authentication failure. What should I do? Jisjo Jisjo Community Answer The error "su: Authentication failure" shows for an incorrect password login. Give the correct password to fix this. Also, there is no command like "sudo - ", refer to the article for correct usage. Thanks! We're glad this was helpful. Thank you for your feedback. If wikiHow has helped you, please consider a small contribution to support us in helping more readers like you. We’re committed to providing the world with free how-to resources, and even $1 helps us in our mission. Support wikiHow Yes No Not Helpful 5 Helpful 9
See more answers Ask a Question 200 characters left Include your email address to get a message when this question is answered. Submit Advertisement

Video

Tips

  • You can use su to access the shell of another user on the system. To become user “jane," type su - jane and then enter YOUR password when prompted (not Jane’s). Thanks Helpful 3 Not Helpful 2
  • Avoid logging in as root as much as possible. You can run almost any superuser-required command withsudo. Thanks Helpful 2 Not Helpful 5
Submit a Tip All tip submissions are carefully reviewed before being published Name Please provide your name and last initial Submit Thanks for submitting a tip for review! Advertisement

You Might Also Like

Install TrueType Fonts on UbuntuHow to Install TrueType (.TTF) Fonts on Ubuntu Linux: Complete Guide Access Windows Files in UbuntuHow to Access Windows Files in Ubuntu OS Become Root in LinuxHow to Access and Use the Root Account in Linux Solve Incorrect Password ...Try Again Error in UbuntuHow toSolve Incorrect Password ...Try Again Error in Ubuntu Open the Root Terminal in Kali LinuxHow to Enable Root in Kali Linux and Open a Root Terminal Change the Root Password in LinuxHow to Change Your Root Linux Password (Even If You Don't Know It) Linux How to Change UserLinux: How to Change User in Terminal & GNOME Sudo Command Not Found2 Ways to Fix the "Sudo Command Not Found" Error on Linux Open Applications With Root Privileges on a MacHow to Run Apps with Root Permissions on a Mac Run a Program from the Command Line on LinuxHow toRun a Program from the Command Line on Linux Set Administrator PasswordHow to Change the Windows Administrator Password Set up an FTP Server in Ubuntu LinuxHow to Install and Configure an FTP Server in Ubuntu Linux How to Add User to a GroupAdding & Managing Users in Linux Groups Zsh: Permission DeniedHow to Fix the Zsh: Permission Denied Error on Mac Advertisement

References

  1. https://help.ubuntu.com/community/UsingTheTerminal
  2. https://help.ubuntu.com/community/RootSudo
  3. https://help.ubuntu.com/community/RootSudo#Graphical_sudo
  4. https://ubuntu.com/tutorials/command-line-for-beginners#3-opening-a-terminal
  5. https://ubuntu.com/server/docs/user-management
  6. https://ubuntu.com/server/docs/user-management
  7. https://ubuntu.com/tutorials/command-line-for-beginners#3-opening-a-terminal
  8. https://access.redhat.com/solutions/64860
  9. https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/6/html/v2v_guide/preparation_before_the_p2v_migration-enable_root_login_over_ssh
More References (1)
  1. https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/6/html/v2v_guide/preparation_before_the_p2v_migration-enable_root_login_over_ssh

About This Article

Nicole Levine, MFA Written by: Nicole Levine, MFA wikiHow Technology Writer This article was co-authored by wikiHow staff writer, Nicole Levine, MFA. Nicole Levine is a Technology Writer and Editor for wikiHow. She has more than 20 years of experience creating technical documentation and leading support teams at major web hosting and software companies. Nicole also holds an MFA in Creative Writing from Portland State University and teaches composition, fiction-writing, and zine-making at various institutions. This article has been viewed 1,232,053 times. How helpful is this? Co-authors: 19 Updated: December 14, 2025 Views: 1,232,053 Categories: Ubuntu Article SummaryX

To run a command as root, type “sudo” before the command. Use “gksudo” if the command opens a program with a Graphical User Interface (GUI). Did this summary help you?YesNo

In other languages Spanish Italian Portuguese Russian German Indonesian Arabic Thai Dutch French Korean Hindi Vietnamese Turkish Chinese Persian Japanese
  • Print
  • Send fan mail to authors
Thanks to all authors for creating a page that has been read 1,232,053 times.

Is this article up to date?

Yes No Advertisement Cookies make wikiHow better. By continuing to use our site, you agree to our cookie policy. Nicole Levine, MFA Written by: Nicole Levine, MFA wikiHow Technology Writer Click a star to vote Co-authors: 19 Updated: December 14, 2025 Views: 1,232,053

Quizzes & Games

Discord Username Idea GeneratorDiscord Username Idea GeneratorGenerate NamesWould I Be a Good Super Spy QuizWould I Be a Good Super Spy QuizTake QuizHow Good Are My Survival Instincts QuizHow Good Are My Survival Instincts QuizTake QuizWhich Video Game Character Am I?Which Video Game Character Am I?Take QuizLeetspeak Translator & GeneratorLeetspeak Translator & GeneratorGenerateAm I Chronically Online QuizAm I Chronically Online QuizTake Quiz

You Might Also Like

Install TrueType Fonts on UbuntuHow to Install TrueType (.TTF) Fonts on Ubuntu Linux: Complete GuideAccess Windows Files in UbuntuHow to Access Windows Files in Ubuntu OSBecome Root in LinuxHow to Access and Use the Root Account in LinuxSolve Incorrect Password ...Try Again Error in UbuntuHow toSolve Incorrect Password ...Try Again Error in Ubuntu

Trending Articles

What Emojis Mean Sex?What Emojis Mean Sex?100+ Flirty Things to Say to a Girl & Boost Her Self-Esteem100+ Flirty Things to Say to a Girl & Boost Her Self-EsteemType A B C D Personality TestType A B C D Personality TestKissing Tips: The wikiHow Guide to the Perfect KissKissing Tips: The wikiHow Guide to the Perfect KissTell That Your Crush Likes You BackHow toTell That Your Crush Likes You BackCat Sleeping Positions: 22 Common Poses ExplainedCat Sleeping Positions: 22 Common Poses Explained

Watch Articles

Calculate the Volume of a PyramidHow toCalculate the Volume of a PyramidThe Best Way to Exfoliate Your Scalp (Plus, What to Use)The Best Way to Exfoliate Your Scalp (Plus, What to Use)Save Money as a KidHow toSave Money as a KidPolish AluminumHow toPolish Aluminum2 Easy Renter-Friendly Options to Hang Your Window Treatments2 Easy Renter-Friendly Options to Hang Your Window Treatments Insert Slide Numbers in PowerPointHow to Insert Slide Numbers in PowerPoint

Trending Articles

Are You Unc? Discover How Old Your Vibe IsAre You Unc? Discover How Old Your Vibe IsWhat's My Hottest Feature QuizWhat's My Hottest Feature QuizGen Beta Slang QuizGen Beta Slang Quiz24 Different Types of Bras Explained24 Different Types of Bras Explained Play the Concentrate Game (For A Little Scare!)How to Play the Concentrate Game (For A Little Scare!)What Does Your Rice Purity Score Really Mean?What Does Your Rice Purity Score Really Mean?

Quizzes & Games

The Impossible QuizThe Impossible QuizTake QuizAm I Smart QuizAm I Smart QuizTake QuizIQ TestIQ TestTake QuizStar Wars Name GeneratorStar Wars Name GeneratorGenerate NamesGamertag GeneratorGamertag GeneratorGenerate NamesAm I a Sigma Male QuizAm I a Sigma Male QuizTake Quiz wikiHow
  • Categories
  • Computers and Electronics
  • Operating Systems
  • Linux
  • Ubuntu
wikiHow Newsletter You're all set! Helpful how-tos delivered toyour inbox every week! Sign me up! By signing up you are agreeing to receive emails according to our privacy policy.
  • Home
  • About wikiHow
  • Experts
  • Jobs
  • Contact Us
  • Site Map
  • Terms of Use
  • Privacy Policy
  • Do Not Sell or Share My Info
  • Not Selling Info
  • Contribute

Follow Us

×

Keep up with the latest tech with wikiHow's free Tech Help Newsletter

Subscribe You're all set! X --785

Từ khóa » đăng Nhập Ubuntu Với Quyền Root