Home > System Tutorial > LINUX > What is the linux switch user command?

What is the linux switch user command?

下次还敢
Release: 2024-04-11 20:51:19
Original
1161 people have browsed it

Linux provides a variety of commands for user switching, mainly including: su command: to switch users, you can specify the -l parameter to switch in login shell mode. sudo command: Run the command as another user. You can specify the -u parameter to specify the user and the -s parameter to switch to the login shell mode.

What is the linux switch user command?

Linux Switch User Commands

Linux provides several commands that allow users to switch between different user accounts switch.

Main commands

su command

  • ##su command is the best way to switch users Common commands.
  • Syntax:
  • su [options] [username]
  • Options:

    • -: Switch to the previous user.
    • -l: Switch users by logging in to the shell.
    • -c: Specifies the command to run as the specified user.

sudo Command The

  • sudo command allows users to run commands as other users.
  • Syntax:
  • sudo [options] [command]
  • Options:

      ##-u
    • : Specify the user as whom to run the command.
    • -s
    • : Run the command as a login shell.
Routine

Switch to user

johndoe

:

    su johndoe
  • Run the
ls

command as the root user:

##sudo - u root ls
  • ##Use sudo
  • to log in to the shell to switch to the
alice

user: sudo -s -u alice

  • Other commands

Besides su and

sudo

In addition, there are some other commands that can be used to switch users: login

: Log in to the specified user account.
  • setpriv: Switch to a user with the specified permission set.
  • runuser: Run the command as the specified user.

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

Related labels:
source:php.cn
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template