bash에서 루트 액세스의 다양한 "유형"을 구별합니까?

bash에서 루트 액세스의 다양한 "유형"을 구별합니까?

무엇입니까?구별사이:

sudo su -

그리고

su -i

그리고 하나가 다른 것보다 선호되는 곳은 어디입니까?

   -, -l, --login
          Start the shell as a login shell with an environment similar to a real login:

             o      clears all the environment variables except TERM and variables specified by --whitelist-environment

             o      initializes the environment variables HOME, SHELL, USER, LOGNAME, and PATH

             o      changes to the target user's home directory

             o      sets argv[0] of the shell to '-' in order to make the shell a login shell

그리고

   su - run a command with substitute user and group ID

페이지 에서 발췌 man su.

답변1

-i명령 에는 인수 가 없으므로 su차이점은 하나는 작동하고 다른 하나는 작동하지 않는다는 것입니다.

을 의미했다면 계정이 잠겨 있고 입력할 비밀번호가 없기 su -l때문에 Ubuntu 상자에서는 기본적으로 작동하지 않습니다 .root

-인수 와 인수 사이에는 차이가 없습니다 -l. 둘 다 동일한 옵션의 변형입니다. 귀하는 실제로 man귀하의 질문에 이를 알려주는 페이지 의 줄을 포함시켰습니다 .

-, -l또는 인수(모두 동일함) 를 사용하는 것과 인수를 사용하지 않는 것의 차이점은 --login게시물에 포함된 발췌문에 대부분 설명되어 있습니다. 이 부분은 인수 없이 수행되는 작업을 알려줍니다.

For  backward compatibility, su defaults to not change the current directory and to only set the environment variables HOME and SHELL (plus USER and LOG‐
NAME if the target user is not root).  It is recommended to always use the --login option (instead of its shortcut -) to avoid  side  effects  caused  by
mixing environments.

참고로 이는 su단지root 아닙니다 . 그것은 의미하지 않습니다슈퍼유저그와 마찬가지로sudo . 그것은 다음을 의미합니다.대체 사용자해당 사용자로 명령을 실행하기 위해 인수로 사용하려는 사용자를 지정할 수 있습니다.

관련 정보