Super users in linux

How do I become superuser on Ubuntu Linux using su/sudo?

I replaced Windows 10 with Ubuntu Linux 16.04 LTS. So, I am a new Ubuntu Linux user. How do I become superuser on Ubuntu Linux? How do I login as root on Ubuntu?

Introduction: On Ubuntu Linux root is a particular user account. By default, the root user has access to all commands, files, services on an Ubuntu Linux operating system. It is also known as the root account, root user and the superuser. The superuser or root user has root privileges. It is the most privileged account on Ubuntu with complete access to everything. The MS-Windows equivalent of root is the Administrators group or Administrator user. This page shows how to log in as root or superuser on Ubuntu to perform sysadmin related tasks.

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements Ubuntu Linux
Est. reading time 3 minutes

How to become superuser on Ubuntu Linux

  1. Open a terminal Window/App. Press Ctrl + Alt + T to open the terminal on Ubuntu.
  2. To become root user type:
    sudo -i
    OR
    sudo -s
  3. When promoted provide your own password.
  4. After successful login, the $ prompt would change to # to indicate that you logged in as root user on Ubuntu.
  5. You can also type the whoami command to see that you logged as the root user.

Let us see all commands and examples in details.

How do I login as root on Ubuntu?

Open the Terminal application. Use the whoami command to verify user identity:
$ whoami
To login as root on Ubuntu, type the following sudo command:
$ sudo -i
Next type your password and your shell promot should change from $ to # :
#
To exit from sudo session of root user, type any one of the following exit command or logout command:
# logout
OR
# exit

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

How to become superuser on Ubuntu Linux using sudo command

The -i option tells sudo to run the shell specified by the root user’s password database entry as a login shell. If you pass the -s to the sudo command, it runs the shell specified by the SHELL environment variable if it exists or the shell defined by the invoking user’s password database entry.

How to become root in Ubuntu Linux using su

By default, the root account password is locked in Ubuntu Linux for security reasons. This means that you cannot login as root directly or use the su command to become the root user. You must set up root password by running the following command in advance on Ubuntu based system:
sudo passwd root
See “How to change root password in Ubuntu Linux” for more info.

Type the following su command:
$ su —
You must know and type root user’s password when prompted:

Login as root on Ubuntu Linux using ‘su -‘ command

su vs sudo to become superuser in Ubuntu Linux

Table 01 – Difference between su and sudo
su command sudo command
You must know the root user’s password. No need to know the root user’s password.
The su command does not log usage or all arguments. The sudo command logs sudo usage and all arguments.
If the root user password not set or root user is disabled, you can not use su command. sudo works with or without a root user password. It uses your password and /etc/sudoers file to authenticate your session.

Conclusion

This tutorial explains how to gain root access in the Ubuntu Linux terminal session using the sudo and su command. I recommend that you always use the sudo command to become root user on Ubuntu. For more info see this page.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Источник

Linux Login as Superuser ( root user )

Linux superuser

In Linux and Unix like computer operating systems, root is the conventional name of the user who has all rights or permissions (to all files and programs) in all modes (single- or multi-user). The root user can do many things an ordinary user cannot, such as changing the ownership of files and binding to ports numbered below 1024. The etymology of the term may be that root is the only user account with permission to modify the root directory of a Unix system.

Linux Login as Superuser

You need to use any one of the following command to log in as superuser / root user on Linux:

  • No ads and tracking
  • In-depth guides for developers and sysadmins at Opensourceflare✨
  • Join my Patreon to support independent content creators and start reading latest guides:
    • How to set up Redis sentinel cluster on Ubuntu or Debian Linux
    • How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
    • How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
    • A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
    • How to protect Linux against rogue USB devices using USBGuard

Join Patreon

  1. su command – Run a command with substitute user and group ID in Linux
  2. sudo command – Execute a command as another user on Linux

How to become superuser in Linux

Let us see some examples of the su and sudo command to become superuser in Linux.

Become a superuser in Linux using sudo command

You must be part of special secondary group on Linux:

  • sudo group on a Debian or Ubuntu Linux
  • wheel group on a CentOS/RHEL/Fedora/Oracle Linux

You can see your secondary group membership by running either groups command or id command $ groups
$ id
Next run the following command to become a root/super user:
$ sudo -i
When promoted type your password to gain root shell.

Log in as a superuser/root user using the sudo command on Linux

Superuser login

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Category List of Unix and Linux commands
Documentation help • mandb • man • pinfo
Disk space analyzers df • duf • ncdu • pydf
File Management cat • cp • less • mkdir • more • tree
Firewall Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04
Linux Desktop Apps Skype • Spotify • VLC 3
Modern utilities bat • exa
Network Utilities NetHogs • dig • host • ip • nmap
OpenVPN CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04
Package Manager apk • apt
Processes Management bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop
Searching ag • grep • whereis • which
Shell builtins compgen • echo • printf
Text processing cut • rev
User Information groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w
WireGuard VPN Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04

Comments on this entry are closed.

i like to learning more about linux

It is interesting to notice how easy it is to find this information on the web, how to login as a superuser, and how it is difficult to find the information about how to log OUT of superuser (exit). Wouldn’t it make sense to put these things together ? I guess that someone who just learnt how to log in as a superuser would also immediately need to know how to log out.
And by the way, your answer after “A” doesn’t answer the questions “Q” at the beginning of the article.

Hey, i tried this but my linux said:
Error with approval ( think thats how you translate it..
its bothering me alot and i tripple checked the password it is correct

what version of lunux are you using? if you are using any ubuntu based linux for example you, you can only use the super user to run comands, you cant stay loged in as the super user.

Ex: to install an aplication, you would opne a terminal and enter

sudo apt-get install name_of_application.

the sudo or su comand will indicate to linux that you are trying to run the comand as the super user or administrator, but in ubuntu after the application is done installing it will go back to regular user to aboid any security breach. y have to realize that the when you are in super user mode it can be verry danguros becasue bc you can do anything, like deleting all you files and messing up your operating system.

so in conclution you get that message because your linux you might not be running any other comands after the sudo or su comand.

i hope that made sense.

i am grave trouble i forgot ma superuser password hw to recover it

I am new to linux, i want to learn more about linux as much possible. i am using ubuntu and suse.
i try to log in as supper user by su command, and provide password i used to login my system but it shows Authentication failure. please guide me.

Thanks and regards

Earlier i used to login to root by typing ip address and port, i just remember the ip address but i forgot the port number, can anybody please help.

I think you are using telnet or ssh, if telnet it is port 23 and for ssh it uses port 22. Hope it helps.

i just now logged in as super user but i want to delete it.what i should do for that.

All you need to do is type: Exit

or press Control D

thanks for this! learning linux command line scripts now after installing fedora in my nephew’s inspiron 1525, was wondering how to get to root user, other sites weren’t explaining well enough so again, thanks a million! 🙂

Being a super user can be VERY dangerous so I suggest you know what your doing if your going to become a super user but another way to get root access is to type into the command line:

Источник

How to Change Users in Linux Command Line

Linux systems have different types of users with different types or permissions as well.

Not all users can execute all commands and not all users are allowed to switch to other users neither. This all might sound confusing but, I will try to explain these so it can be easy to understand.

For the moment, here’s a quick summary of how to switch users in Linux command line.

To switch users, you need to know the password of that user. You can switch the users with this command:

To switch to root user in Ubuntu, you can use this command:

Various user types in Linux

If you list all users in Linux, you’ll see a lot of users that you didn’t know about. Who are these users? Where did they come from? I could write an entire article in regards of how users work in Linux, however, this is not the idea for this one.

Basically, there are 3 types of users in Linux:

1. System Users

These are the users that are automatically created in Linux systems to be able to run services or applications and are not intended to log in to the system (in fact you can’t log in as any of these users).

2. Regular Users

These are the (human) users who can log in to a system. Each of these users might have or not different permissions or levels in the system which is given by the groups they belong to.

3. Super Users

These are system administrators or users who can perform high-level tasks that can be considered critical or system dangerous.

Switch users in the command line

When using a Linux system you can log in with a user and then simply “switch” to another user through the same command line session. In order to do this, there is a command “su -“, which allows you to switch to become another user:

In the above example, you need to know the password of janedoe in order to switch to that user. Which makes sense because if you are going to switch to a user, you need to know the password of that user else it will be a security risk.

Switch to root user

For security reasons, some systems have ‘root’ account blocked for direct login, either locally or remotely, so this means it will not accept someone who tries to log in using ‘root’ even with the correct password.

So, how do you perform actions as the ‘root’ user? That’s what the ‘sudo’ command allows you to.

The sudo command will basically execute anything you want in the system as if the ‘root’ was doing it. You don’t need to know the ‘root’ user’s password, in fact, probably nobody knows it or there is no password assigned to ‘root’. You only need to know your own user’s password and that user must be in the ‘sudoers’ group, which is basically the group of users which can use ‘sudo’ in the system.

Normally, it is a good practice to run the commands with sudo that needs to run with root permission like this:

But if you want to change to root user so that all the subsequent commands will be run as root, you can use:

You’ll use your own password here, not the root account’s password.

As a sudo user yourself, you can create sudo user by adding the user to sudo group.

Conclusion

Linux systems allow you to easily switch users or execute high-level commands with the usage of ‘su‘ and ‘sudo’ commands. And remember: with great sudo power comes great responsibility!

Источник

Читайте также:  Диск с 100 нагрузка windows 10 при запуске
Оцените статью