The password of su is the password of the root user; when installing a Linux or Unix operating system, the user will be prompted to enter the password of root. This is also the password that the user will enter after executing the "sudo su" command. . The full name of su is "switch user", which allows the user to temporarily change the login identity. Except for root, the user account and password to be changed must be entered when changing.
#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.
What does the su password mean?
# The password of su is the password of the root user. When installing a Linux or Unix operating system, it will There is a prompt asking you to enter the root password. This is the password that appears after you execute the sudo su command and asks you to enter the password. Note that this password will not display asterisks or other symbols. It will always be blank. Press Enter after completing the input. Just fine.
su command introduction
su (full English spelling: switch user). In Linux, the su command allows users to temporarily change the login identity. Except for root, the user account and password to be changed must be entered when changing.
Usage permissions: All users.
Function:Change the user identity. If the user account is not specified, the default will be changed to root.
Syntax
su [-fmp] [-c command] [-s shell] [--help] [--version] [-] [USER [ARG]]
Parameter description:
-f or --fast does not need to read the startup file (such as csh. cshrc, etc.), only used for csh or tcsh
-m -p or --preserve-environment does not change the environment variables when executing su
-c command or --command=command Change to the user whose account is USER and execute the command (command) and then change back to the original user
-s shell or --shell =shell specifies the shell to be executed (bash csh tcsh, etc.), the default value is the user (USER) in /etc/passwd shell
--help display description file
--version Display version information
- -l or --login After adding this parameter, it will be like logging in again for this use Like the user, most environment variables (HOME SHELL USER, etc.) are based on the user (USER), and the working directory will also change. If USER is not specified, the default is root
USER User account to be changed
ARG Pass in new shell parameters
Common examples :
Example 1: Change the account to root and exit back to the original user after executing the ls command
Command: su -c ls root
Change the account to root and exit back to the original user after executing the ls command.
[root@localhost ~]# su -c ls root 公共 视频 文档 音乐 anaconda-ks.cfg 模板 图片 下载 桌面 initial-setup-ks.cfg
Example 2: Switch user
Command: su root
Switching testuser to root is equivalent to changing the user to Root but operating in the testuser environment
Switching between small permissions and large permissions requires entering a password; switching between large permissions and small permissions does not require entering a password.
Switching users can only obtain the user's execution permissions, but not environment variables.
[testuser@localhost ~]$ whoami //显示当前用户 testuser [testuser@localhost ~]$ pwd //显示当前目录 /home/testuser [testuser@localhost ~]$ su root //切换到root用户 密码: [root@localhost testuser]# whoami root [root@localhost testuser]# pwd /home/testuser
Example 3: Switch users and change environment variables
Command: su - root
Switch testuser to root, It is equivalent to changing the user to root and operating in the root environment. That is, change the account to root and change the working directory to root's home directory.
Switch to the user and obtain the user's environment variables and execution permissions.
[testuser@localhost ~]$ whoami testuser [testuser@localhost ~]$ pwd /home/testuser [testuser@localhost ~]$ su - root 密码: [root@localhost ~]# whoami root [root@localhost ~]# pwd /root
The difference between su and su -
Note that when using the su command, there is a completely different difference between - and without - option. It means that when switching user identities, even the currently used environment variables are also switched to those of the specified user. We know that environment variables are used to define the operating system environment. Therefore, if the system environment does not switch with the user's identity, many commands cannot be executed correctly.
For example, the ordinary user lamp switches to the root user through the su command, but does not use the - option. In this case, although it appears to be the root user, the $PATH environment variable in the system is still lamp's. (rather than root), so the current working environment does not include the saving paths of superuser commands such as /sbin, /usr/sbin, etc., which makes many administrator commands unable to be used at all. Not only that, when the root user accepts mail, he will find that the mail received is from the lamp user, because the environment variable $MAIL has not been switched.
Beginners can understand the difference between them in this way, that is, with the - option, switching the user identity is more complete; on the contrary, only a part of it is switched, which will cause problems or errors in running certain commands ( For example, the service command cannot be used).
Through the following example, you can intuitively see the difference between su and su -:
[lamp@localhost ~]$ whoami lamp #查询用户身份,我是lamp [lamp@localhost ~]$ su root 密码: <-输入root密码 #切换到root,但是没有切换环境变量。注意:普通用户切换到root需要密码 [root@localhost ~]# env | grep lamp #查看环境变量,提取包含lamp的行 USER=lamp #用户名还是lamp,而不是root PATH=/usr/lib/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/lamp/bin #命令査找的路径不包含超级用户路径 MAIL=/var/spool/mail/lamp PWD=/home/lamp LOGNAME=lamp #邮箱、主目录、目前用户名还是lamp
You can see that without using su -, although the user identity is successful Switch, but the environment variables are still those of the original user, and the switch is incomplete.
Related recommendations: "Linux Video Tutorial"
The above is the detailed content of What does linux su password mean?. For more information, please follow other related articles on the PHP Chinese website!

The five core components of the Linux operating system are: 1. Kernel, 2. System libraries, 3. System tools, 4. System services, 5. File system. These components work together to ensure the stable and efficient operation of the system, and together form a powerful and flexible operating system.

The five core elements of Linux are: 1. Kernel, 2. Command line interface, 3. File system, 4. Package management, 5. Community and open source. Together, these elements define the nature and functionality of Linux.

Linux user management and security can be achieved through the following steps: 1. Create users and groups, using commands such as sudouseradd-m-gdevelopers-s/bin/bashjohn. 2. Bulkly create users and set password policies, using the for loop and chpasswd commands. 3. Check and fix common errors, home directory and shell settings. 4. Implement best practices such as strong cryptographic policies, regular audits and the principle of minimum authority. 5. Optimize performance, use sudo and adjust PAM module configuration. Through these methods, users can be effectively managed and system security can be improved.

The core operations of Linux file system and process management include file system management and process control. 1) File system operations include creating, deleting, copying and moving files or directories, using commands such as mkdir, rmdir, cp and mv. 2) Process management involves starting, monitoring and killing processes, using commands such as ./my_script.sh&, top and kill.

Shell scripts are powerful tools for automated execution of commands in Linux systems. 1) The shell script executes commands line by line through the interpreter to process variable substitution and conditional judgment. 2) The basic usage includes backup operations, such as using the tar command to back up the directory. 3) Advanced usage involves the use of functions and case statements to manage services. 4) Debugging skills include using set-x to enable debugging mode and set-e to exit when the command fails. 5) Performance optimization is recommended to avoid subshells, use arrays and optimization loops.

Linux is a Unix-based multi-user, multi-tasking operating system that emphasizes simplicity, modularity and openness. Its core functions include: file system: organized in a tree structure, supports multiple file systems such as ext4, XFS, Btrfs, and use df-T to view file system types. Process management: View the process through the ps command, manage the process using PID, involving priority settings and signal processing. Network configuration: Flexible setting of IP addresses and managing network services, and use sudoipaddradd to configure IP. These features are applied in real-life operations through basic commands and advanced script automation, improving efficiency and reducing errors.

The methods to enter Linux maintenance mode include: 1. Edit the GRUB configuration file, add "single" or "1" parameters and update the GRUB configuration; 2. Edit the startup parameters in the GRUB menu, add "single" or "1". Exit maintenance mode only requires restarting the system. With these steps, you can quickly enter maintenance mode when needed and exit safely, ensuring system stability and security.

The core components of Linux include kernel, shell, file system, process management and memory management. 1) Kernel management system resources, 2) shell provides user interaction interface, 3) file system supports multiple formats, 4) Process management is implemented through system calls such as fork, and 5) memory management uses virtual memory technology.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver Mac version
Visual web development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

WebStorm Mac version
Useful JavaScript development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment
