search
HomeComputer TutorialsComputer KnowledgeHow to switch users in Linux system?

How to switch users in Linux system?

Feb 19, 2024 pm 01:10 PM
userswitchOrder

How to switch users in Linux system?

Linux is a multi-user, multi-tasking, multi-threading and multi-CPU operating system based on POSIX and Unix. It supports multiple users to log in and operate at the same time, so in Linux Switching users is one of the very common operations. So how to switch users in Linux system? The following is an introduction to common commands.

 1.su command

su command is a common command used to switch users. Through the su command, you can switch to other user accounts in the terminal and perform corresponding operations. When using the su command, you need to provide the credentials of the target user account, usually the password. For example, to switch to the root user, enter the su command in the terminal and enter the root user's password. The use of the su command helps to perform tasks as different users in the system and improve operation permissions.

 ”’shell

su – root

 ”’

This command will prompt you to enter the password of the root user. After entering the correct password, you can execute the command under the root user.

 2. sudo command

The sudo command allows ordinary users to run specific commands with superuser privileges and is usually used for operations that require administrator privileges. When using sudo in the terminal, the user is asked to enter their own password to confirm authentication. For example, when executing commands that require root privileges, you can use the sudo command to elevate privileges.

 ”’shell

 sudo command

 ”’

This command will prompt you to enter the password of the current user. After entering the correct password, you can execute the command with the permissions of the root user.

 3. su -l command

The -l option of the su command can switch to the specified user account and switch the environment variables to the environment variables of the specified user. Enter the following command in the terminal to switch users:

 ”’shell

 su -l username

 ”’

 Where username is the user account to be switched to. This command will prompt for the password of the specified user. After entering the correct password, you can execute the command under that user.

 4. Login command

The login command is used to switch users and log in to the system again. When using the login command, you need to enter the user account and password you want to switch to. For example, enter the following command in the terminal to switch users:

 ”’shell

 login

 ”’

 This command will prompt you to enter the user account and password to switch to. After entering the correct account and password, the system will log in as the user again.

The above is the detailed content of How to switch users in Linux system?. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:每日运维. If there is any infringement, please contact admin@php.cn delete
Must-Know Fixes - Cannot Type Password on the Login ScreenMust-Know Fixes - Cannot Type Password on the Login ScreenApr 24, 2025 am 12:50 AM

Unable to type password at login screen Windows 7/8/10/11? Why does this issue occur? What should you do when you cannot type password on the login screen? This post from php.cn provides you with several feasible solutions to this matter.

[Solved] macOS Cannot Verify That This App Is Free from Malware - MiniTool[Solved] macOS Cannot Verify That This App Is Free from Malware - MiniToolApr 24, 2025 am 12:49 AM

Have you encountered the “macOS cannot verify that this app is free from malware” notification when running apps on Mac? This post from php.cn shows you how to solve this problem.

3 Targeted Solutions for Error Code 2000-0415 on Dell3 Targeted Solutions for Error Code 2000-0415 on DellApr 24, 2025 am 12:48 AM

Error code 2000-0415 is a small issue that is connected to some specific cables of your computer. It is pretty common in Dell devices. If you receive this error at the moment, the tips and tricks of this post on php.cn Website will be helpful to you.

Computer Freezes But Mouse Still Moves - Results-Driven MethodsComputer Freezes But Mouse Still Moves - Results-Driven MethodsApr 24, 2025 am 12:47 AM

Have you ever encountered a situation where the computer freezes but mouse still moves? Many people are troubled by this problem and they choose to forcefully shut down their computers. In fact, there are other methods that can help you solve this pr

Windows 7 Ultimate SP1 Free Download and Install (32/64 Bits) - MiniToolWindows 7 Ultimate SP1 Free Download and Install (32/64 Bits) - MiniToolApr 24, 2025 am 12:46 AM

Some users still use the Windows 7 edition and they want to download Windows 7 Ultimate SP1. However, they don’t know where to find the ISO file. Don’t worry! This post from php.cn tells you how to free download and install  Windows 7 Ultimate SP1.

Is Your Spectrum DVR Not Working? Try These Fixes! - MiniToolIs Your Spectrum DVR Not Working? Try These Fixes! - MiniToolApr 24, 2025 am 12:45 AM

What will you do if there is a conflict between your favourite TV shows and work appointments? Spectrum DVR can help you out! It allows you to record your favourite games or TV shows and watch them whenever you want. If you are plagued by Spectrum DV

How to Enable Selection Checkboxes in File Explorer Windows 10 - MiniToolHow to Enable Selection Checkboxes in File Explorer Windows 10 - MiniToolApr 24, 2025 am 12:44 AM

Do you have any idea how to show or remove checkboxes in File Explorer? If not, you’ve come to the right place. This paper on php.cn shows you a couple of feasible ways to enable selection checkboxes in File Explorer.

5 Fixes for VSS Error 0x800423F4 When Backup in Win10/115 Fixes for VSS Error 0x800423F4 When Backup in Win10/11Apr 24, 2025 am 12:43 AM

VSS error 0x800423F4 happens when creating a system image on Windows 11/10. If you are plagued by this annoying issue, follow the fixes collected by php.cn to root out it. Besides, professional Windows backup software like php.cn ShadowMaker is intro

See all articles

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 Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

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

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment