Skip to content

필사 모드: Difference Between Linux su and su - Commands

English
0%
정확도 0%
💡 왼쪽 원문을 읽으면서 오른쪽에 따라 써보세요. Tab 키로 힌트를 받을 수 있습니다.
원문 렌더가 준비되기 전까지 텍스트 가이드로 표시합니다.

Overview

When using Linux, there are times when you need to log in as the superuser `root` without logging out of the current account.

The commands used for this are `su root` or `su - root`. By default, if no user name is specified, the su command logs in as root.

Let's look at the difference between the su and su - commands for switching users.

su (Switch User) Command

When you enter the `su` command in the shell, it switches to the `root` user while keeping the current environment variables.

su

su - (Switch User) Command

When you enter `su -` in the shell, it logs in as `root` and also changes the directory to root's home directory.

The previous environment variables are discarded.

sh -

In this case, the environment variables defined in `~/.bash_profile` or `~/.bashrc` under the root account are loaded.

In summary, the difference between the `su` and `su -` commands is whether or not the previous user's environment variables are loaded before the dash.

This concludes the post about the Linux commands for switching users. Thank you.

Quiz

Q1: What is the main topic covered in "Difference Between Linux su and su - Commands"?

Learn the difference between the su and su - commands in Linux.

Learn the difference between the su and su - commands in Linux.

Consider the practical examples and patterns discussed throughout the post.

현재 단락 (1/15)

When using Linux, there are times when you need to log in as the superuser `root` without logging ou...

작성 글자: 0원문 글자: 1,141작성 단락: 0/15