จากsu
หน้าคนของ:
For backward compatibility, su defaults to not change the current directory
and to only set the environment variables HOME and SHELL (plus USER and LOGNAME
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.
...
-, -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
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
เป็นการยากที่จะบอกว่ามีความแตกต่างระหว่าง-
และ--login
(หรือควรจะ-l
) กล่าวคือ man page บอกว่า "แทนที่จะเป็นทางลัด -" แต่ตัวเลือกทั้งหมดเหล่านี้ถูกจัดกลุ่มเข้าด้วยกันและฉันไม่เห็นคำอธิบายของความแตกต่างหากมีอยู่จริง
UPDฉันจะตรวจสอบคำถามที่ซึ่งควรจะแก้ปัญหาของฉัน คำถามคือโดยทั่วไปเกี่ยวกับความแตกต่างระหว่างและsu
su -
และฉันถามเกี่ยวกับความแตกต่างระหว่างและsu -
su --login
ไม่เลยไม่แก้ปัญหาเลย
ฉันไม่ทราบคำจำกัดความของคุณที่ซ้ำกัน แต่ฉันไม่พิจารณาคำถามของฉันเช่นนี้ คำถามที่คุณแนะนำคือโดยทั่วไปเกี่ยวกับความแตกต่างระหว่างและ
—
x-yuri
su
su -
และฉันถามเกี่ยวกับความแตกต่างระหว่างและsu -
su --login
ฉันหายไปนี่อะไร
To avoid side effects caused by mixing environments use --login option or its equivalent -. The first form is recommended because - can be placed only just before username.