Linux can login as root

How to enable root login?

I would like to enable the root account on my Ubuntu installation. I realize the security implications of this.

5 Answers 5

Warning

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).

to unlock the account. This should return

passwd: password expiry information changed 

Reverting

If you want to disable root account in Ubuntu you need to lock the root account by using the following command sudo passwd -l root

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

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.

Note: Running users-admin with elevated privileges no longer works because of a bug that is marked as «Won’t Fix» for security reasons. See https://bugs.launchpad.net/ubuntu/+source/gnome-system-tools/+bug/685215 for an explanation.

im1

pkexec users-admin will open the users screen:

Documentation

The link only explains why it’s bad to login as root and doesn’t give any reason why it’s bad to have a root account. As it is on any system with recovery mode, the root account still exists and so if not «enabled» root shell needs no password.

I performed the above steps, but there is still no possibilitie to login as root at the start page. Only my user name and guest.

I have an Ubuntu VM and after following this procedure I can log in as ‘root’ from the console, but I cannot ssh in as ‘root’.

You can enable the root account by setting the password as

while it is not recommended at all. From help Ubuntu

Enabling the Root account is rarely necessary. Almost everything you need to do as administrator of an Ubuntu system can be done via sudo or gksudo. If you really need a persistent Root login, the best alternative is to simulate a Root login shell using the following command.

Use at your own risk!

Logging in to X as root may cause very serious trouble. If you believe you need a root account to perform a certain action, please consult the official support channels first, to make sure there is not a better alternative.

Once enable you can disable the root account as

Читайте также:  Hosts file port linux

Here are the links to enable root login for Ubuntu 12.04 & Ubuntu 12.10

In Linux there is a special account called root. By default it is locked in Ubuntu but you can enable the root account.

This is normally not a good idea however and you should consider very carefully before enabling the root login.

There are several good reasons not to login as root but use sudo instead including

  • Users don’t have to remember an extra password (i.e. the root password), which they are likely to forget (or write down so anyone can crack into their account easily).
  • It avoids the «I can do anything» interactive login by default (e.g. the tendency by users to login as an «Administrator» user in Microsoft Windows systems), you will be prompted for a password before major changes can happen, which should make you think about the consequences of what you are doing.
  • sudo adds a log entry of the command(s) run (in /var/log/auth.log). If you mess up, you can always go back and see what commands were run. It is also nice for auditing.
  • Every cracker trying to brute-force their way into your box will know it has an account named Root and will try that first. What they don’t know is what the usernames of your other users are. Since the Root account password is locked, this attack becomes essentially meaningless, since there is no password to crack or guess in the first place.
  • Allows easy transfer for admin rights, in a short term or long term period, by adding and removing users from groups, while not compromising the Root account. sudo can be setup with a much more fine-grained security policy.

This is discussed in more detail in the RootSudo Comunity Documentation

If you have a number of commands which would normally require sudo you can type sudo -i before the first command then exit after the last to avoid repeatedly typing sudo. To run a GUI application with root priviledges press ALT + F2 and enter gksu or gksudo followed by the name of your program (unless you are using the KDE desktop in which case the command is kdesu .

For example gksu nautilus runs the file manager with root privileges.

As you can see it is almost never necessary to enable the root login.

That said to enable the root login all that is required is to set a root password

and set a password. You will then be able to login as root but for all the reasons I have given above and more I would not recommend you do it.

Читайте также:  Gcc include path 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.

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 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.

Источник

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