Table of Contents
1.2 SUID permissions of binary files" >1.2 SUID permissions of binary files
2. setuid and setresuid functions" >2. setuid and setresuid functions
Function prototype: int setuid(uid_t uid);" >##2.1 setuid functionFunction prototype: int setuid(uid_t uid);
getuid returns the " >3. getuid and geteuid functions getuid returns the

What is the use of linux uid

Mar 13, 2023 am 09:40 AM
linux uid

The function of linux uid is to identify a user, each user has a UID; there are three UID identifiers in Linux: 1. RUID, Real UID, actual user ID; 2. EUID, Effective UID, effective User ID; 3. SUID, Saved Set-user-ID, saved set user ID.

What is the use of linux uid

#The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.

What is the use of linux uid?

UID in Linux

In Linux, UID is used to identify a user (such as alice, bob, root)
In Android , UID is used to identify an application or system service

1. UID in Linux

1.1 Three UID values ​​for each process

Each user has a UID.

The kernel maintains 3 UID identifications for each process. The three UID identifiers are RUID (Real UID, actual user ID) , EUID (Effective UID, effective user ID) , SUID (Saved Set-user-ID , saved settings user ID).

  • RUID: Which user are we currently logged in as? The RUID of the process we run the program to generate is the UID of this user.
  • EUID: refers to which UID the current process actually runs as . Under normal circumstances, EUID is equal to RUID; but if the executable file corresponding to the process has SUID permission (that is, the s of rws), then the EUID of the process is the UID## of the owner of the executable file. #.
  • SUID: A copy of EUID, related to SUID permissions.

1.2 SUID permissions of binary files

Take the executable file passwd as an example.

The permissions of the password file are:
-rwsr-xr-x The owner of passwd is root, but other users also have execution permissions for passwd, and passwd itself has SUID permissions (s of rws) .
Then, when a non-root user executes the passwd executable file, the EUID
of the generated process is the UID of the root user. In other words, in this case, the process generated actually runs the binary file with the ID of the root user.

It should be noted that

SUID permissions are time-sensitive: is only valid during the execution of the file .

2. setuid and setresuid functions

##2.1 setuid functionFunction prototype: int setuid(uid_t uid);

In Linux, the execution steps of the setuid(uid) function are:

(1) If called by a Root privileged process (a process with EUID 0), set the RUID, EUID and SUID of the process. is uid, returns 0

(2) If called by a normal permission process, and uid is equal to RUID or uid is equal to SUID, set the EUID of the process to uid, and returns 0
(3) If called by a normal permission process , and uid is not equal to RUID or SUID, set errno to EPERM and return -1 (indicating execution failure)

In the above, the process of executing password, EUID is the UID of the owner of password, which is root The user's UID, which is 0. Therefore, it belongs to case (1). The

su file also has

-rwsr-xr-x

permissions. Therefore, in Android, when a normal process initiates a shell process through Runtime.getRuntime().exec("su") to execute su, it also falls into the situation (1).

2.2 setresuid function

Reference https://blog.csdn.net/damotiansheng/article/details/39674115

Function prototype: int setresuid(uid_t ruid, uid_t euid, uid_t suid);

When one of the following conditions

is met, setresuid is executed: ①The euid of the current process is root (AID_ROOT) ② Each of the three parameters ruid, euid, and suid is equal to a certain UID value of the current process

For example:

If the current process RUID=100, EUID=0, SUID=300
    then setresuid(200,300,100) can be executed because the original euid=0

  • If the current process's RUID=100, EUID=300, SUID=200
  • Then setresuid(200,300,100) can be executed, because these three parameters are all one of the current UID;
  • But setresuid(100,200,400) cannot be executed, because 400 is not equal to any of the current UID.

3. getuid and geteuid functions getuid returns the

RUID of the current process

geteuid returns the of the current process EUID
Related recommendations: "

Linux Video Tutorial

"

The above is the detailed content of What is the use of linux uid. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1668
14
PHP Tutorial
1273
29
C# Tutorial
1256
24
Where to view the logs of Tigervnc on Debian Where to view the logs of Tigervnc on Debian Apr 13, 2025 am 07:24 AM

In Debian systems, the log files of the Tigervnc server are usually stored in the .vnc folder in the user's home directory. If you run Tigervnc as a specific user, the log file name is usually similar to xf:1.log, where xf:1 represents the username. To view these logs, you can use the following command: cat~/.vnc/xf:1.log Or, you can open the log file using a text editor: nano~/.vnc/xf:1.log Please note that accessing and viewing log files may require root permissions, depending on the security settings of the system.

How debian readdir integrates with other tools How debian readdir integrates with other tools Apr 13, 2025 am 09:42 AM

The readdir function in the Debian system is a system call used to read directory contents and is often used in C programming. This article will explain how to integrate readdir with other tools to enhance its functionality. Method 1: Combining C language program and pipeline First, write a C program to call the readdir function and output the result: #include#include#include#includeintmain(intargc,char*argv[]){DIR*dir;structdirent*entry;if(argc!=2){

Linux Architecture: Unveiling the 5 Basic Components Linux Architecture: Unveiling the 5 Basic Components Apr 20, 2025 am 12:04 AM

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

How to install PHPStorm in Debian system How to install PHPStorm in Debian system Apr 13, 2025 am 06:03 AM

Install PHPStorm on the Debian system to easily solve your PHP development environment! The following steps will guide you through the entire installation process. Installation steps: Download PHPStorm: Visit the official website of JetBrains and download the latest version of PHPStorm. Unzip the installation package: After downloading using wget or curl, unzip it to the specified directory (for example /opt). Command example: wgethttps://download.jetbrains.com/phpstorm/phpstorm-2024.3.5.tar.gztar-xzfphpstorm-2024.3.5.tar.gz

How to recycle packages that are no longer used How to recycle packages that are no longer used Apr 13, 2025 am 08:51 AM

This article describes how to clean useless software packages and free up disk space in the Debian system. Step 1: Update the package list Make sure your package list is up to date: sudoaptupdate Step 2: View installed packages Use the following command to view all installed packages: dpkg--get-selections|grep-vdeinstall Step 3: Identify redundant packages Use the aptitude tool to find packages that are no longer needed. aptitude will provide suggestions to help you safely delete packages: sudoaptitudesearch '~pimportant' This command lists the tags

How to locate memory leaks in Tomcat logs How to locate memory leaks in Tomcat logs Apr 13, 2025 am 08:18 AM

This article introduces how to troubleshoot memory leaks through Tomcat logs and related tools. 1. Memory monitoring and heap dump First, use tools such as JVisualVM or jstat to monitor Tomcat's memory usage in real time, observe the changes in the heap memory, and determine whether there is a memory leak. Once a leak is suspected, use the jmap command to generate a heap dump file (heap.bin): jmap-dump:format=b,file=heap.bin, which is the Tomcat process ID. 2. Heap dump file analysis Use EclipseMemoryAnalyzerTool (MAT) or other tools to open the heap.bin file and analyze the memory.

Debian system OpenSSL vulnerability fix Debian system OpenSSL vulnerability fix Apr 13, 2025 am 06:12 AM

To ensure the security of OpenSSL on the Debian system, please follow the following steps: 1. System update: First, update your Debian system to the latest version. Use the following command to update the package list and upgrade all installed software: sudoaptupdatesudoaptupgrade 2. Version confirmation: Check the current OpenSSL version: opensslversion 3. OpenSSL upgrade: If the version is too old, please upgrade. Method 1: Direct upgrade (recommended): Use the following command to directly upgrade to the latest stable version of OpenSSL: sudoaptinstall--only-upgrade

How Debian improves Hadoop data processing speed How Debian improves Hadoop data processing speed Apr 13, 2025 am 11:54 AM

This article discusses how to improve Hadoop data processing efficiency on Debian systems. Optimization strategies cover hardware upgrades, operating system parameter adjustments, Hadoop configuration modifications, and the use of efficient algorithms and tools. 1. Hardware resource strengthening ensures that all nodes have consistent hardware configurations, especially paying attention to CPU, memory and network equipment performance. Choosing high-performance hardware components is essential to improve overall processing speed. 2. Operating system tunes file descriptors and network connections: Modify the /etc/security/limits.conf file to increase the upper limit of file descriptors and network connections allowed to be opened at the same time by the system. JVM parameter adjustment: Adjust in hadoop-env.sh file

See all articles