A
A
Asparagales2018-10-25 17:07:37
linux
Asparagales, 2018-10-25 17:07:37

Why is it not recommended to use root privileges on the command line?

Maybe a stupid question, but I don't understand. Why is it highly discouraged to work with the root account on the command line, but instead use the sudo command?

Answer the question

In order to leave comments, you need to log in

11 answer(s)
S
Saboteur, 2018-10-25
@saboteur_kiev

> The question may be stupid, but I do not understand. Why is it highly discouraged to work with the root account on the command line, but instead use the sudo command?
You misread the recommendation. It is not recommended to log in to the machine on behalf of the root. That is, the root user must be blocked from being able to log in.
In Linux, you cannot create multiple administrator users, because the system architecture implies that all system processes run on behalf of the user with the ID 0, and the user with this ID has full access. Therefore, leaking a password from such a user, especially if there are many different users on the machine, is fraught with difficulties. And the password to the root user is constantly trying to guess scriptkiddy.
Therefore, it is recommended to create a personal user and configure his access through the sudo command, so that each privileged user will log in with his own password, and if necessary, perform an administrative action using sudo.
Technically, logging in as root and executing a command, or executing a command via sudo (if you have permissions) is practically the same.
The recommendation applies exclusively to login as root using the credentials of the root user.

S
Softer, 2018-10-25
@Softer

Because when by chance something like rm -rf / gets into the console ... :)
In general, there is much less chance of making a mistake.

V
Vladimir Kuts, 2018-10-25
@fox_12

In addition to the above, I insisted on using my sudo accounts, with a ban on logging in as root, because it is easier to find from the logs who executed some command with sudo rights from their account than to figure out who exactly used the root user.

F
Fixid, 2018-10-25
@Fixid

One bad typo can destroy data

V
Vyacheslav Uspensky, 2018-10-25
@Kwisatz

It's not just about mistakes and other nuances. You can just accidentally or thoughtfully hit enter. For the same reason, it is recommended to write a where block in the SQL console before update/delete

P
pfg21, 2018-10-25
@pfg21

From under the user you will shoot only the user's data.
You will shoot the whole system from under the root.
For a single-user home machine, this is equivalent. In the sense of pofih can be restored without haste.
For a production server in production, this is an asshole and a huge expense.
Therefore, a minimum of operations are performed on the server from under the root, if it turns out, then one at all - synchronization of the system with a test machine on which the innovations are debugged and tested.

A
Alexander Chernykh, 2018-10-25
@sashkets

it is possible with root rights, if carefully

R
Roman Ratkin, 2018-10-25
@Hanharr

Haven't seen it recommended that way. Usually it is recommended to simply not work as root. For a lot of things you don't need full rights, having full rights is a great chance to break something.
Often seen as an example, they put the launch of a script in which Barmin's patch is veiled somewhere:
rm -rf /

V
Vladimir, 2018-10-25
@MechanID

It depends on the tasks:
If you constantly manage hundreds or thousands of servers,
and you need, for example, to make a lot of edits in different config files, update software, use utilities like tcpdump, then it’s easier to work as root right away, though you should immediately realize that the cost of an error may be great.
If you manage a desktop and you need to install some software once a month, it's better to use sudo.

C
CityCat4, 2018-10-26
@CityCat4

Because until there is a complete and clear understanding of what you are doing, it is better not to take risks. One team "in the wrong window" - and you frantically remember whether there was a backup and, if so, when. Well, if it happened on your own work car. What if it happened on the server? Have you ever been in such a situation? Well, you get...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question