Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Nov 2023 10:46:20 -0800
From:      Freddie Cash <fjwcash@gmail.com>
To:        mike tancsa <mike@sentex.net>
Cc:        FreeBSD-STABLE Mailing List <freebsd-stable@freebsd.org>
Subject:   Re: csh to sh migration for root in RELENG_14
Message-ID:  <CAOjFWZ4FRv2%2BG3BoXSV2fb%2BxaH7jLZp6rmrxJmus_8TbSgbRAQ@mail.gmail.com>
In-Reply-To: <6c6add3c-4a5e-4d84-9964-9a9448a36c95@sentex.net>
References:  <6c6add3c-4a5e-4d84-9964-9a9448a36c95@sentex.net>

next in thread | previous in thread | raw e-mail | index | archive | help
--000000000000011e72060a5d8e77
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Fri, Nov 17, 2023 at 10:41=E2=80=AFAM mike tancsa <mike@sentex.net> wrot=
e:

> I am trying to bring my environment along from previous versions where
> csh was the default shell and now trying to get used to sh. In the past
> things like
>
> sudo su
>
> would pick up my settings in /root/.cshrc automatically. However, with
> sh I have to do
>
> sudo su -l root
>
> Is there a way to configure it so I dont need the -l as part of the su
> to get the same behavior ?
>
>
> e.g.
>
> - 0 mike@mfitest1:~ $ su
> Password:
> # ^D
> - 0 mike@mfitest1:~ $ su -l root
> Password:
> - 0 root@mfitest1:~ #
>
> with su -l root, I get all the settings I have in .profile. Without '-l
> root', I am not sure what is getting set from where. But its different
> as I can see  it in the prompt being different ?
>

su by itself just switches your username, it doesn't pick up the rest of
the environment settings like a proper login does.
su - is what you are looking for, as that simulates a real login, picking
up all the environment settings of the new user.

sudo su -

The reason it "worked" before is that you were changing shells when
changing users, so it would read the shell startup config files.  But it
was still using the environment of the previous user.  Now that both users
are using the same shell, you have to force the "simulate login" part.

Check the output of things like PATH and HOME and what not between your
normal user and switching users via:
sudo su
sudo su -

You'll be (mildly?) surprised by the output.  :)


--=20
Freddie Cash
fjwcash@gmail.com

--000000000000011e72060a5d8e77
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr">On Fri, Nov 17, 2023 at 10:41=E2=80=AFAM =
mike tancsa &lt;<a href=3D"mailto:mike@sentex.net">mike@sentex.net</a>&gt; =
wrote:<br></div><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote=
" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);=
padding-left:1ex">I am trying to bring my environment along from previous v=
ersions where <br>
csh was the default shell and now trying to get used to sh. In the past <br=
>
things like<br>
<br>
sudo su<br>
<br>
would pick up my settings in /root/.cshrc automatically. However, with <br>
sh I have to do<br>
<br>
sudo su -l root<br>
<br>
Is there a way to configure it so I dont need the -l as part of the su <br>
to get the same behavior ?<br>
<br>
<br>
e.g.<br>
<br>
- 0 mike@mfitest1:~ $ su<br>
Password:<br>
# ^D<br>
- 0 mike@mfitest1:~ $ su -l root<br>
Password:<br>
- 0 root@mfitest1:~ #<br>
<br>
with su -l root, I get all the settings I have in .profile. Without &#39;-l=
 <br>
root&#39;, I am not sure what is getting set from where. But its different =
<br>
as I can see=C2=A0 it in the prompt being different ?<br></blockquote><div>=
<br></div><div>su by itself just switches your username, it doesn&#39;t pic=
k up the rest of the environment settings like a proper login does.</div><d=
iv>su - is what you are looking for, as that simulates a real login, pickin=
g up all the environment settings of the new user.</div><div><br></div><div=
>sudo su -</div><div><br></div><div>The reason it &quot;worked&quot; before=
 is that you were changing shells when changing users, so it would read the=
 shell startup config files.=C2=A0 But it was still using the environment o=
f the previous user.=C2=A0 Now that both users are using the same shell, yo=
u have to force the &quot;simulate login&quot; part.</div><div><br></div><d=
iv>Check the output of things like PATH and HOME and what not between your =
normal user and switching users via:</div><div>sudo su</div><div>sudo su -<=
/div><div><br></div><div>You&#39;ll be (mildly?) surprised by the output.=
=C2=A0 :)</div><div><br></div></div><div><br></div><span class=3D"gmail_sig=
nature_prefix">-- </span><br><div dir=3D"ltr" class=3D"gmail_signature">Fre=
ddie Cash<br><a href=3D"mailto:fjwcash@gmail.com" target=3D"_blank">fjwcash=
@gmail.com</a></div></div>

--000000000000011e72060a5d8e77--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAOjFWZ4FRv2%2BG3BoXSV2fb%2BxaH7jLZp6rmrxJmus_8TbSgbRAQ>