Note: For help with configuring sudo privileges via its configuration file /etc/sudoers, please see Sudoers.
Run the command mentioned below to enable the account:
$ sudo -i
The password can then be updated using either the «sudo passwd root» or «» command.
$ sudo -s
$ sudo su —
$ sudo — root
After enabling the account using the above command, the password can be updated using either the «sudo passwd root» or «» command.
- We can help you
- How to login as a root in the GNOME desktop
- Enable root account
- Change GDM configuration
- Configure PAM authentication
- Log in as root
- Things you should know when running the system as a root user
- What is root user? Why is it locked in Ubuntu?
- How to run commands as root user in Ubuntu?
- How to become root user in Ubuntu?
- How to enable root user in Ubuntu?
- Re-disabling your root account
- Usage
- For 12. 0 LTS or earlier
- Reset sudo timeout
- Warning
- Adding and Deleting Users
- Where is root?
- Alternatives to root login
- Преимущества использования sudo
- Graphical version needs setting up 1st
- Password Policy
- Minimum Password Length
- Password Expiration
- Other Resources
- Как включить рута в Ubuntu
- Как зайти под root в Ubuntu Desktop GUI
- Graphical sudo
- Flavour-specific workarounds
- General workarounds
- Logging in as another user
- Enabling
- Allowing other users to run sudo
- Benefits of using sudo
- Drag & Drop Sudo
We can help you
Думаете, с вами такого не случится? Даже опытные администраторы Linux рассказывают жуткие истории о том дне, когда они сделали роковую опечатку или не задумывались над тем, что они делают, работая под именем суперпользователя.
По умолчанию учетная запись суперпользователя отключена в Ubuntu. Это означает, что вы не сможете зайти в систему как root. Однако, инсталлятор настраивает sudo для пользователя, созданного во время установки. Команда sudo позволяет выполнять все приложения, требующие привилегий суперпользователя.
Когда sudo спрашивает пароль, вы должны ввести пароль ВАШЕГО пользователя ! То есть пароль root’a вам не нужен !
I want to login as root, but when I enter
and enter password, this message is shown: «you are not in sudoers file», and when I enter
and enter password, this is shown: «authentication failure».
My os has one account only. about past1 hours ago I log on as root and do some commands , when I logout , I can’t login another time!
124 gold badges465 silver badges653 bronze badges
asked Dec 30, 2011 at 18:38
answered Dec 30, 2011 at 19:03
1 gold badge16 silver badges24 bronze badges
Be aware that the root account is not active by default.
You will need to do:

102 gold badges136 silver badges162 bronze badges
answered Jun 28, 2013 at 23:22
5 silver badges2 bronze badges
The https://help.ubuntu.com/community/RootSudo suggests:

56 gold badges215 silver badges327 bronze badges
answered Dec 30, 2011 at 19:00

1 gold badge38 silver badges43 bronze badges
this will add you to the sudoers group! Then type exit and boot normally. when you enter your account, type:
Then enter your password and type the new root password
After that you can type su and enter the ‘root’ password.
If you don’t want to change the root password then you can use:
to start a root shell, using your own password.
answered Mar 5, 2014 at 14:53
12 gold badges30 silver badges43 bronze badges
По умолчанию в операционной системе Ubuntu учетная запись root не включена во время установки, соответственно далее пользователю не предлагается создать пароль root. Вместо этого создаётся обычная учетную запись пользователя, но с привилегиями sudo. То есть, для выполнения каких-либо команд с правами рута, необходимо запускать их вместе с командой sudo. Это не всегда удобно! Сейчас я расскажу как зайти под Root в Ubuntu или дать пользователю права рута. Существует несколько вариантов и мы рассмотрим каждый из них!
Примечание: Перед тем, как включить пользователя root в Убунту, Вы должны понимать всю опасность этого для неопытного пользователя. Выполняя команды от его имени, Вы можете легко и просто, буквально за несколько команд, привести операционную систему в нерабочее состояние.
Первый и самый простой вариант позволяет не вводить постоянно команду sudo при каждом вводе команды, которую надо выполнить в привилегированном режиме. Для перехода в полный режим рута введите такую команду:
После этого Вы перейдёте в привилегированный режим суперпользователя Убунту.
Есть и второй вариант:
В этом случае домашний каталог не сменится на /root, а останется пользовательский. Как правило, этот вариант удобнее.
By default, Ubuntu disables the root account. You must use the sudo command for any tasks requiring root privileges.
This is for your own security, of course. Using the system as root all the time is like running around with a sword in your hand. It increases the chances of messing up things.
Logging in as root is still common in the servers. On the desktop side, it’s quite rare to log in as root. Even Kali Linux has changed it.
in this guide, I will show you how to log in as a root in your GNOME desktop using Ubuntu.
How to login as a root in the GNOME desktop
I won’t advise login as root on the desktop. You have sudo mechanism for all your root needs. Do it only if you have a good enough reason. This tutorial is for demo purposes only. You have been cautioned.
Enable root account
You want to log in as root. But the root account is disabled by default. The first step is to enable it.
Change the root account password that will eventually enable the root account for you:

It goes without saying that you should not forget the root password.
Change GDM configuration
Ubuntu uses GNOME by default and GNOME uses the GDM display manager.
To allow log in as root into GNOME, you need to make some changes in the GDM configuration file located at /etc/gdm3/custom.conf.
Make a backup of the config file:
cp /etc/gdm3/custom.conf /etc/gdm3/custom.conf~
In the worst case, if you somehow mess things up, the back up file can be used to replace the existing one from the TTY.
sudo nano /etc/gdm3/custom.conf

Press Ctrl+X to exit Nano while saving it.
Configure PAM authentication
sudo nano /etc/pam.d/gdm-password
Save changes and exit from the nano text editor.
Log in as root
Now, reboot your system:

Logging as root (Click to enlarge)
That’s it! Now, you are running your Ubuntu system as a root.
Things you should know when running the system as a root user
There is a reason why Ubuntu disables a root account by default. Want to know why? Here you have it:
Either you run commands with root privilege like this:
What is root user? Why is it locked in Ubuntu?
You don’t need to have root privilege for your daily tasks like moving file in your home directory, downloading files from internet, creating documents etc.
Take this analogy for understanding it better. If you have to cut a fruit, you use a kitchen knife. If you have to cut down a tree, you have to use a saw. Now, you may use the saw to cut fruits but that’s not wise, is it?
Does this mean that you cannot be root in Ubuntu or use the system with root privileges? No, you can still have root access with the help of ‘sudo’ (explained in the next section).
How to run commands as root user in Ubuntu?
So, how do you run commands as root? The simple answer is to add sudo before the commands that require to be run as root.
sudo apt update
If you are absolutely new to Linux, you might be surprised that when you start typing your password in the terminal, nothing happens on the screen. This is perfectly normal because as the default security feature, nothing is displayed on the screen. Not even the asterisks (*). You type your password and press enter.
Bottom line:To run commands as root in Ubuntu, add sudo before the command.When asked for password, enter your account’s password.When you type the password on the screen, nothing is visible. Just keep on typing the password and press enter.
How to become root user in Ubuntu?
The sudo command allows you to simulate a root login shell with this command:
You’ll notice that when you switch to root, the shell command prompt changes from $ (dollar key sign) to # (pound key sign). This makes me crack a (lame) joke that pound is stronger than dollar.
If you try to use the su command without sudo, you’ll encounter ‘su authentication failure’ error.
How to enable root user in Ubuntu?
Again, this is not recommended and I won’t encourage you to do that on your desktop. If you forgot it, you won’t be able to change the root password in Ubuntu again.
sudo passwd -dl root
I hope you have a slightly better understanding of the root concept now. If you still have some confusion and questions about it, please let me know in the comments. I’ll try to answer your questions and might update the article as well.
To enable the root account (i.e. set a password) use:
Use at your own risk!
Re-disabling your root account
To use sudo on the command line, preface the command with sudo, as below: Example #1
sudo chown bob:bob /home/bob/*
sudo /etc/init.d/networking restart
To repeat the last command entered, except with sudo prepended to it, run:
Usage
Не рекомендуется это делать!
Consider using the below command instead:
Использование этой команды временно откроет консоль с правами root. Активация аккаунта root в Ubuntu не поддерживается из-за ненадобности. Всё, что вам требуется сделать с правами администратора в Ubuntu можно сделать через sudo или gksudo.
Если root включен, и вы хотите отключить его, откройте терминал и введите следующую команду:
sudo passwd -l root
For 12. 0 LTS or earlier
During boot, press and hold Shift (for BIOS) or ESC (for UEFI). This will bring up the Grub2 boot menu from where we can select «recovery mode» (usually the second boot entry).

This will lead to the Grub2 recovery menu:

«Drop to root shell prompt» gives you a command line root environment from where you can access your files as root (no sudo required). After having done your work on your files you can leave the command line shell by
Choose «Resume normal boot» to proceed booting as usual.
Note: see this question for a solution when the Grub recovery menu does not load the shell.
Reset sudo timeout
You can make sure sudo asks for password next time by running:
Warning
While it’s possible to do, it is not recommended.
Adding and Deleting Users
Пример #1 — смена пользователя и группы для файлов в домашней папке пользователя
Пример #2 — перезапуск сетевых служб
sudo -i (эквивалент команды «sudo su -«)
sudo -s (эквивалент команды «sudo su»)
Where is root?
These instructions are to remove the prompt for a password when using the sudo command. The sudo command will still need to be used for root access though.
Edit the sudoers file
michael ALL=NOPASSWD: ALL
Type in ^x to exit. This should prompt for an option to save the file, type in Y to save.
Log out, and then log back in. This should now allow you to run the sudo command without being prompted for a password.
Or to do this for the system wide group sudo
Log out, and then back in.
Alternatives to root login
If you want to work on a root console you can also use sudo -i.
Only do this if you know what you are doing. More information on why to stay with sudo here
Преимущества использования sudo
Причины, по которым пользователь root отключен по умолчанию, заключаются в следующем:
Graphical version needs setting up 1st
pkexec gnome-terminal will open a terminal with a root prompt.
passwd root will allow you to create a password for root.
Password Policy
A strong password policy is one of the most important aspects of your security posture. Many successful security breaches involve simple brute force and dictionary attacks against weak passwords. If you intend to offer any form of remote access involving your local password system, make sure you adequately address minimum password complexity requirements, maximum password lifetimes, and frequent audits of your authentication systems.
Minimum Password Length
By default, Ubuntu requires a minimum password length of 6 characters, as well as some basic entropy checks. These values are controlled in the file /etc/pam.d/common-password, which is outlined below.
If you would like to adjust the minimum length to 8 characters, change the appropriate variable to min=8. The modification is outlined below.
Password Expiration
None of the methods below are suggested or supported by the designers of Ubuntu.
To start a root shell (i.e. a command window where you can run root commands), starting root’s environment and login scripts, use:
sudo -i (similar to sudo su — , gives you roots environment configuration)
To start a root shell, but keep the current shell’s environment, use:
sudo -s (similar to sudo su)
Summary of the differences found —
For a detailed description of the differences see man su and man sudo .
Other Resources
CategoryCommandLine CategorySecurity CategoryCommandLine
Как включить рута в Ubuntu
Вы всегда можете включить корневую учетную запись root в Ubuntu, задав ей пароль с помощью команды passwd. Но чтобы запустить команду passwd для учетной записи root, вам нужны права sudo.
Мы можем включить корневую учетную запись Ubuntu, задав ей пароль с помощью команды passwd. Но чтобы запустить команду passwd для учетной записи root, вам нужны права sudo.
Откройте терминал Ubuntu и выполните команду, чтобы убедиться, что вы являетесь членом группы администраторов:
Если у вас есть соответствующие права, то вы можете установить пароль root с помощью следующей команды:
Сначала система запросит ввод Вашего собственного пароля, чтобы подтвердить, что у вас есть права sudo.
Далее последует запрос запроса пароля — введите пароль для root.
Как зайти под root в Ubuntu Desktop GUI
Если вы хотите зайти в систему как пользователь root не в консоли, а на графическом рабочем столе Ubuntu, тогда вам нужно выполнить несколько дополнительных шагов после включения пользователя root:
Затем откройте файл и найдите такую строку:
Закомментируйте её, поставив знак # перед ней:
Graphical sudo
Please note that many websites and old threads advise the use of gksu. However, such search results are obsolete. gksudo has not been updated for years and is not even available in Bionic (18.04) and higher. gksu has been replaced by pkexec, but even pkexec is being deprecated by the mainline Ubuntu developers. They have taken the position that file manipulation and editing under root should be restricted to the command line.
Flavour-specific workarounds
There are a number of flavour-specific options for running graphical applications as root:
General workarounds
During boot, press and hold Shift (for BIOS) or ESC (for UEFI). This will bring up the Grub2 menu from where we can select «Advanced options for Ubuntu».

After that we will be able to select the kernel we wish to boot in «Recovery mode»:

This will lead us to the advanced options. By selecting «Enable networking» we gain access to our network and the internet for upgrades or downloads, and we will also mount our hard drives in read/write mode in case we need to edit files.

After the network has loaded, and fielsystems were mounted we will be presented again with the menu, from where we can choose «Drop to a root shell prompt»:

If we had not enabled read/write access with «Enable networking» the filesystem will be mounted read only, and we are unable to edit files.
mount -o rw,remount /
From the root shell type exit to go back to the menu.
Logging in as another user
sudo -i -u amanda
The password being asked for is your own, not amanda’s.
Enabling
To actually enable root logins first you have to set a password for the root account and then unlock the locked root account. If you don’t set a password for the root account the passwd command will return
passwd: unlocking the password would result in a passwordless account.
So, first execute in a terminal
you will be prompted for a new Unix password. Write it twice (second for confirmation).
sudo passwd -u root
to unlock the account. This should return
passwd: password expiry information changed
Allowing other users to run sudo
In the terminal (for Precise Pangolin, 12.04), this would be:
In previous version of Ubuntu
Benefits of using sudo
There are a number of benefits to Ubuntu leaving root logins disabled by default, including:
Drag & Drop Sudo
Этот трюк взят из форумов.
Создайте кнопку запуска со следующей командой:
gksudo «gnome-open %u»
Теперь при перетаскивании любого файла на эту кнопку, будет запущено ассоциированное с этим файлом приложение с привилегиями суперпользователя. Это особенно удобно при редактировании конфигурационных файлов.






