Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux basic command-switch user su

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Su

Temporarily switch identity to another user, after switching users with su, the current working directory will not be changed, but some environment variables will be changed.

The scope of this command: RedHat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.

1. Grammar

Su [options] [parameters]

2. List of options

Option

Description

-- help

Show help documentation

-- version

Show command version

-|-l |-- login

Start a new shell when switching users, and you can change the working directory and environment variables

-c |-- command

Restore your original identity immediately after the execution of the case instructions

-- session-command=COMMAND

Use-c to pass a single command to shell without creating a new session.

-f |-- fast

Make shell not read the startup file

-m |-p |-- preserve-environment

Retain the original environment variables

-s |-- shell

Specify the shell to be used after switching users

3. Examples

1) switch users

[root@192 weijie] # su david / / switch users, the environment variable has not changed

[david@localhost weijie] $

2) use the option "-" to switch

[root@localhost weijie] # su-david / / use the option "-", the working directory has changed

[david@localhost ~] $

3) switch from other users to root

[david@localhost ~] $su / / does not have any options or parameters, so you can switch directly to the root user. You need to enter a password.

Password:

[root@localhost david] #

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report