[Liunx]: root initial password setting

foreword

Time cannot be met, and Tao cannot be done in vain.


1. The difference between "users" in Linux

1. Ordinary users and privileged users

  • windowsThere are ordinary users and privileged users in the system. Privileged users are administer, and there can be many ordinary users. Privileged users are system administrators who have operation rights to all files in the system. Each ordinary user can only process its own files and cannot access them. Files of other users, not to mention operating system files.
  • Similarly, Linuxthere is also a difference between ordinary users and privileged users. Privileged users are root rootusers , and the rights of ordinary users are restricted. For example, ordinary users cannot cd / root, and ordinary users cannot use apt-get installto install software.

2. Conversion command~

  • ~: Represents the host directory of the current user (the so-called host directory is the default directory designed by the operating system for the current user to store files and work, such as the "My Documents" directory Windowsin Windows, LinuxIn , each user has its own home directory. For ordinary users, this directory is at: /home/username/, and for rootusers (administrators), it is at: /root.

2. Initial password setting of root in Liunx

  • When the Linux operating system is just installed, it is not possible Terminalto run sucommands , because root does not have an initial password, and we need to manually set it manually.

Specific steps to set a password for the root user

  1. Open a terminal and enter the following command:
sudo passwd root
  • After pressing Enter, you will be prompted to enter the original password, new password and confirm the new password:

insert image description here

The difference between su and sudo is:

  1. The password for su is that of root, and the password for sudo is that of the user
  2. su directly changes the identity to root, and sudo is to run commands as root after the user logs in, without knowing the root password.

Guess you like

Origin blog.csdn.net/WandZ123/article/details/126910613