Login linux as root users

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.

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.

Читайте также:  Linux create live usb

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 switch to root on Linux

Linux users will inevitably need to log into the root account, or use administrator privileges, quite frequently. Tasks like installing or removing software, configuring system settings, adjusting file permissions, and many others usually require access to the root user account in order to perform. The root account can be accessed either by logging directly into the account, or by using the sudo Linux command to temporarily access root and execute a command with administrator privileges. In this tutorial, we will show you how to change to the root account on a Linux system, and how to use sudo to execute commands with root privileges.

In this tutorial you will learn:

  • How to log in to the root account
  • How to use the sudo command
  • How to open a new terminal as the root user

How to switch to root on Linux

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System Any Linux distro
Software N/A
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

How to Switch to Root User on Linux

Here are a few different methods to switch to the root user on Linux. Depending on your Linux distribution and the way your user is configured (i.e., whether they have sudo access or not), you may find that one method works better than another, so try them all.

    The majority of Linux distributions come with the sudo convention configured by default for the user that is set up during installation. If your user has access to the sudo command, then you can switch to the root account by appending the -i option, like so:

Logging into the root user account by using the sudo command in Linux

After providing your sudo password, you will be logged into the root account and no longer required to continue prefacing your commands with sudo in order to run them with root privileges.
Alternatively, there is no reason to log into the root user account if you have access to the sudo command and simply want to run a few commands as the root user. This is actually the recommended approach, as it is more secure than having users to log into the root account directly. For example, to run a command as root, preface it with sudo :

Although we are running this command as an ordinary user, the whoami command shows us the effective user that is running the command, which is root.

DID YOU KNOW?
See our tutorial on giving a user sudo permissions if your account has not yet been configured to use the sudo command.

WARNING
The above command will only work if the root account has a password configured. On some systems, the root account does not have a password by default, and instead is expected to be accessed strictly via sudo as shown in the above methods.

Читайте также:  Как загрузить linux grub

If your root account does not have a password and you need to set one, you can execute the following command. Note that this is going against security recommendations.

Closing Thoughts

In this tutorial, we saw how to switch to the root user account on a Linux system. The recommended approach is to use the sudo command in order to execute commands with root privileges, but we can also log directly into the root user account, either with the sudo -i or su — commands, depending on how our system and user account has been configured.

Источник

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. В этой небольшой статье мы рассмотрим как это сделать.

Читайте также:  Точка монтирования при установки линукс

Как зайти под 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