How to login root in linux

How Do I Become a Root User in Linux

The root is the super-user account on Linux-based operating systems. The root user has all the rights that are necessary to perform administrative tasks or access some files, execute privileged commands, and much more. The root user is also referred to as a superuser or root.

In Linux, you can run privileged commands using the sudo keyword. However, sometimes it becomes a tedious act when you are doing administrative tasks and each command requires root privileges. To get rid of such a situation, become a root user and then execute commands.

This article provides various possibilities to become a root user on Linux.

How do I become a root user on Linux

As discussed earlier the root user has the necessary privileges to execute and perform various tasks on Linux-based systems. This section demonstrates Linux commands that can be used to become a root user on Linux.

How to use the sudo command to become a root user

The sudo command allows a normal user to perform the tasks that a superuser can do. Here, we provide the possible usages of the sudo command to become a root user.

Using the “sudo su –”

The `su` refers to switching the user and if the username is not provided, it will switch you to a root user, and the command provided below assists in this regard.

Graphical user interface Description automatically generated with low confidence

After successful authentication, it is noted that we are now switched to a root user.

Using the “sudo su”

The command written below will change the privileges to the root user.

A screenshot of a computer Description automatically generated with medium confidence

Using the “sudo -i”

The command provided below will change the privileges to a root user.

Graphical user interface Description automatically generated with low confidence

The output shows that the dollar sign($) has been replaced by the pound key(#) which also directs that you are currently logged in using the root privileges.

Using “sudo -s”

The “-s” parameter enables the user to run the shell with a specific user. And if the username is not specified then the root (default) is considered.

Text Description automatically generated

How to use su command to become a root user

The su command allows you to switch the user to someone else by providing its username. However, if the name is not specified, the su command would allow you to execute the commands with root privileges.

There are various parameters that would allow you to become a root user.

Using “su –”

A screenshot of a computer Description automatically generated with medium confidence

Using “su -l”

A screenshot of a computer Description automatically generated with medium confidence

Using “–login”

A screenshot of a computer Description automatically generated with medium confidence

It is observed from the above outputs that you are switched to the root user and can now perform the privileged tasks.

During the authentication of su command, you have to put the root password.

Читайте также:  Building mail server linux

Note: In case you are unable to execute the above commands, you must set the password for root by using the following command.

Text Description automatically generated

Bonus Tip

Once you are logged in as a root user, it is recommended to check whether you are working with root privileges or not. To do so, the $LOGNAME variable would help, as the $LOGNAME contains the user you are currently logged in as.

For instance, we have tried to switch to the root user using the “su” command, and let’s check the logged-in user with the help of the following command.

Graphical user interface Description automatically generated with low confidence

The output shows that you are not logged in using the root privileges.

Conclusion

The root user is the ultimate boss of a Linux system, it can perform any task without any hurdle. This guide intends to explore the possible commands or ways to become a root user on Linux so that the frequent authentication hurdle can be avoided. Lastly, it is concluded that the sudo and su keywords are the main stakeholder to become a root user on Linux-based machines. The sudo requires the password of the currently logged-in user whereas the su requires the password of the target user.

Источник

How to become root in Linux

root in linux

Computer Hope

On every Linux system, the root account is a special user with administrative rights. Logging in as root (or executing commands with root privileges) is necessary for many tasks. If you need to perform tasks as the root user, make sure you fully understand the commands you are running, and what consequences they have. A single careless or malformed command, run as root, can make the entire operating system unusable. Do your research, and always double-check every command before pressing Enter .

Logging in as root

The root account is similar to any other account in that it has a username («root») and a password. If you know root’s password, you can use it to log into the root account from the command line.

There is a special command named su (for «super user,» or «switch user») that lets you run commands as the root account temporarily. From the command line, type:

Enter the password once prompted for the password. If successful, you are switched to the root user and can run commands with full system privileges.

Be careful while logged in as root. It is easy to forget you’re currently the root user, and you might inadvertently run a command thinking you are only a mere mortal. One way to remind yourself if you are root or not is to check your command prompt. Many systems end their command prompt with a dollar sign («$«) if you’re logged in as a normal user and a pound sign («#«) if you’re root.

Or, you can use the whoami command to determine the account you are using.

When finished with your administrative tasks, you can run the exit or logout command to return to your standard user account.

When logging in as root, it is often useful to use a single dash after the su command, like this:

This command simulates a complete root login. It executes all of the root user’s shell initialization scripts and sets all environment variables as if the root logged in to a fresh shell session. Depending on what task you need to perform, and how root is configured, this form of the su command might be optimal for you.

Читайте также:  Wireless hacking with kali linux

Running commands as root without the root password

It is possible, and often preferable, to run commands as root without logging into the root account using the sudo command, which stands for «superuser do.» If you prefix a command with sudo, you are prompted for your password (not the root password), and your name is checked against a special file called sudoers. If your account is listed there, your command runs with root privileges.

Using sudo makes it difficult to forget you’re root since you’re not logged in to the root account, and are never going to forget to log out. Also, typing sudo every time you run a potentially destructive command reminds you to be extra careful and double check yourself.

If you need to add a user to the sudoers list, use the visudo command that requires root privileges to run, and lets you safely edit the sensitive sudoers file.

Источник

How To Login As Root User In Linux?

How To Login As Root User In Linux?

The root user is the most privileged user in Linux and Unix systems. The root user is equal to the Administrator in Windows. The root user has the right to read, write and execute all files in a Linux system. The root user comes from the Unix systems. The root user also exists in Unix-like operating systems like BSD, AIX, MacOS, Android, etc. The root user is important because some actions can be only accomplished by the root user.

Root Login via Graphical Desktop Environment

Even Linux is mostly command line based operating system it provides different desktop environments for GUI experience. There are different desktop environments like GNOME, KDE, LXDE, XFCE etc. The GUI desktop environment can be used to login as root user. The login manager provides the ability to login as root user. If you are using the GNOME and the login screen looks like below just click to the “Not Listed?” under the user list. The GNOME do not list the root user by default so we will enter the root username manually.

We will see the following screen where we can enter the root username. Just type root and press Enter key.

In the following screen the password for root user is provided.

Root Login via Terminal

The terminal is used to login to a Linux system and manages via a command-line interface. The root user can log in via the terminal. In bahs shell or terminal, the su command is used to login as the root user. Even the current user is not root we can use the terminal to log in as a root user.

Root Login via SSH

SSH or Secure Shell is a protocol used to login to systems remotely and manage via command-line interface. The SSH can be used in order to login as a root. The SSH uses ssh command or tools like Putty. The root username is provided before the remote host IP address or hostname. The following ssh command can be used to login as root.

Источник

Как зайти под root в Ubuntu

Политика дистрибутива Ubuntu нацелена на то, что все действия, требующих административных привилегий надо выполнять с помощью команды sudo. Использовать root пользователя как основного для новичков опасно, поскольку они ещё плохо ориентируются в системе и могут забыть, что они вошли как root и удалить что-то важное.

А поскольку восстановить файлы, удалённые с помощью команды rm почти нельзя, то лучше новичков туда не пускать. Но иногда возникает необходимость войти под пользователем root. В этой небольшой статье мы рассмотрим как это сделать.

Читайте также:  Lenovo s21e 20 linux

Как зайти под root в Ubuntu

По причинам, описанным выше для пользователя root пароль в Ubuntu не задан по умолчанию, поэтому вы не можете просто так войти от его имени с помощью в виртуальных консолях доступных по Ctrl+Alt+FN или с помощью утилиты su. Поскольку пароля нет, ввести его верно вы не сможете.

Но это всё очень просто обходится. Для того чтобы войти под пользователем root в терминале достаточно дописать sudo перед командой su:

Также можно использовать опцию -i команды sudo чтобы открыть консоль от имени суперпользователя:

Однако, если вы хотите авторизоваться от имени этого пользователя в виртуальной консоли или по SSH, то вам надо сначала задать для него пароль. Для этого выполните:

Затем введите два раза пароль. После этого пользователь root становится почти полноценным пользователем системы. Вы не сможете только войти под ним в графический интерфейс потому что на это действует ограничение самой оболочки Gnome, это очень плохая практика — запускать целую оболочку от имени root.

Но если вам всё же очень хочется, надо немного настроить правила PAM для GDM. Для этого откройте файл /etc/pam.d/gdm-password и закомментируйте там строчку:

sudo vi /etc/pam.d/gdm-password

# auth required pam_succeed_if.so user != root quiet_success

После этого вы сможете авторизоваться от имени root в менеджере входа. Просто кликните по пункту Нет в списке, а затем введите логин root:

Перед вами откроется оболочка, запущенная от имени суперпользователя:

Это очень небезопасно, потому что любая программа может делать с вашим компьютером всё, что захочет и никто её не остановит. Фактически, первые версии Windows тоже работали в таком режиме и поэтому они были очень уязвимы к вирусам.

Обнаружили ошибку в тексте? Сообщите мне об этом. Выделите текст с ошибкой и нажмите Ctrl+Enter.

Похожие записи

Оцените статью

Статья распространяется под лицензией Creative Commons ShareAlike 4.0 при копировании материала ссылка на источник обязательна .

Об авторе

Основатель и администратор сайта losst.ru, увлекаюсь открытым программным обеспечением и операционной системой Linux. В качестве основной ОС сейчас использую Ubuntu. Кроме Linux, интересуюсь всем, что связано с информационными технологиями и современной наукой.

4 комментария к “Как зайти под root в Ubuntu”

Ну а что там с другими DE? Решение я знаю, но почему их нет в статье? Огласите весь список, пожалуйста! Ответить

Поставил два дня назад Ubuntu, просто посмотреть что за зверь такой Linux. Посмотрел. Теперь понял почему Windows рулит в мире, а Linux в глубокой попе ) Если после установки в Windows сразу можно работать (копировать, вставлять файлы, создавать папки редактировать и тд), то в Linux НИЧЕГО нельзя делать. То есть вообще ничего. Разве что браузер работает и можно что то посмотреть. А для того чтобы получить разрешение на работу в Linux, надо сначала выучить команды терминала ) Окститесь линуксоиды! Какой идиот сейчас будет заморачиваться с командами? Современная молодежь даже не знает что такое терминал. Почитал заклинания линуксоидов: какие страшные картинки рисуют, если юзер зашел под root. Чуть ли не конец света ) Как будто в Windows нет важных файлов, а все важнейшие для юзера файлы только в Linux ) Вы вообще про переустановку системы слышали? Если нет, сообщаю: Linux гораздо проще переустановить, чем Windows, не надо активировать систему. Так что заходим под root, спокойно что то ломаем и спокойно переустанавливаем. Никакой трагедии. По крайней мере такая дикая защита от ЮЗЕРА не нужна. Ответить

Источник

Оцените статью
Adblock
detector