Home >Operation and Maintenance >Linux Operation and Maintenance >What is the most powerful account in Linux?

What is the most powerful account in Linux?

青灯夜游
青灯夜游Original
2022-09-19 17:28:588431browse

The account with the most authority in Linux is "root". Root (root user) is a super administrator account. It is named because it can perform read, write and execution operations on the root directory; it can do anything and use everything in the system, access any files and run anything on the Linux system. Order. Root has all the permissions of the system. If the root password is leaked, the data of all users on the entire computer will be completely stolen.

What is the most powerful account in Linux?

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

The account with the most authority in Linux is "root".

Root, also known as the root user, is the only user in Unix (such as Solaris, AIX, BSD) and UNIX-like systems (such as Linux, QNX, etc.), as well as Android and iOS mobile device systems. Superuser, so named because it can perform read, write, and execute operations on the root directory.

Root is the super administrator account, it can do anything and use everything in the system. It can access any file and run any command on your Linux system.

The greater the ability, the greater the responsibility. The root user gives you complete control over the system, therefore, it should be used with caution. The root user can access system files and run commands that change system configuration. Therefore, a wrong command can destroy the system.

Root has all the permissions of the system. If the root password is leaked, it is enough to cause the entire computer to be completely controlled by the person who steals the root password. Having the root password means owning all the users on this computer. all data.

This is why Ubuntu and other Ubuntu-based distributions lock the root user by default, to save you from unexpected disasters.

For your daily tasks, like moving files in your home directory, downloading files from the Internet, creating documents, etc., you do not need to have root privileges.

Let’s use an analogy to understand it better. Suppose you want to cut a piece of fruit, you can use a kitchen knife. Suppose you want to cut down a tree, you have to use a saw. Now, you could use a saw to cut the fruit, but that wouldn't be wise, would it? _

Does this mean that you cannot be the root user in Ubuntu or cannot use the system with root privileges? No, you can still have root access with the help of sudo (explained in the next section).

Points: For routine tasks, the root user rights are too powerful. This is why it is not recommended to use the root user all the time. You can still use the root user to run special commands.

How to run commands as root user in Ubuntu?

What is the most powerful account in Linux?

For some system-specific tasks, you will need root privileges. For example. If you want to update Ubuntu via the command line, you cannot run the command as a regular user. It will give permission denied error.

apt update
Reading package lists... Done
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)

So, how do you run commands as the root user? The simple answer is to add sudo before the command to run it as root.

sudo apt update

Ubuntu and many other Linux distributions use a special program mechanism called sudo. sudo is a program that controls access to running commands as the root user (or other user).

In fact, sudo is a very versatile tool. It can be configured to allow a user to run all commands as root, or just some commands. You can also configure it to run commands using sudo without requiring a password. This topic is quite rich, maybe I will discuss it in detail in another article.

For now, you should know that when you install Ubuntu, you must create a user account. This user account works as an administrator on your system, and according to the default sudo policy in Ubuntu, it can run any command with root user privileges on your system.

The problem with sudo is that running sudo does not require the root user password, but rather the user's own password.

And this is why when you run a command using sudo, you are asked to enter the password of the user who is running the sudo command:

[email protected]:~$ sudo apt update
[sudo] password for abhishek:

As you can see in the example above abhishek is trying to use sudo to run the apt update command, and the system asks for abhishek's password.

If you are completely new to Linux, you may be surprised that nothing happens on the screen when you start typing your password in the terminal. This is quite normal as as a default security feature nothing will be displayed on the screen. Not even an asterisk (*). Enter your password and press Enter.

Key Point: To run commands as root in Ubuntu, add sudo before the command. When asked for a password, enter the password for your account. When you enter your password on the screen, you see nothing. Please continue entering your password and press Enter.

如何在 Ubuntu 中成为 root 用户?

你可以使用 sudo 来像 root 用户一样运行命令。但是,在某些情况下,你必须以 root 用户身份来运行一些命令,而你总是忘了在命令前添加 sudo,那么你可以临时切换为 root 用户。

sudo 命令允许你来模拟一个 root 用户登录的 shell ,使用这个命令:

sudo -i
[email protected]:~$ sudo -i
[sudo] password for abhishek:
[email protected]:~# whoami
root

你将注意到,当你切换为 root 用户时,shell 命令提示符从 $(美元符号)更改为 #(英镑符号)。我开个(拙劣的)玩笑,英镑比美元强大。

虽然我已经向你显示如何成为 root 用户,但是我必须警告你,你应该避免作为 root 用户使用系统。毕竟它有阻拦你使用 root 用户的原因。

另外一种临时切换为 root 用户的方法是使用 su 命令:

sudo su

如果你尝试使用不带有的 sudo 的 su 命令,你将遇到 “su authentication failure” 错误。

你可以使用 exit 命令来恢复为正常用户。

exit

如何在 Ubuntu 中启用 root 用户?

现在你知道,root 用户在基于 Ubuntu 发行版中是默认锁定的。

Linux 给予你在系统上想做什么就做什么的自由。解锁 root 用户就是这些自由之一。

如果出于某些原因,你决定启用 root 用户,你可以通过为其设置一个密码来做到:

sudo passwd root

再强调一次,不建议使用 root 用户,并且我也不鼓励你在桌面上这样做。如果你忘记了密码,你将不能再次在 Ubuntu 中更改 root 用户密码。(LCTT 译注:可以通过单用户模式修改。)

你可以通过移除密码来再次锁定 root 用户:

sudo passwd -dl root

相关推荐:《Linux视频教程

The above is the detailed content of What is the most powerful account in Linux?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn