Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Feb 2004 16:11:40 +0000
From:      Matthew Seaman <m.seaman@infracaninophile.co.uk>
To:        gerard-seibert@rcn.com
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Newbie Questions Regarding <SU> Command & Running Periodic Updating
Message-ID:  <20040215161140.GA86037@happy-idiot-talk.infracaninophile.co.uk>
In-Reply-To: <!~!UENERkVCMDkAAQACAAAAAAAAAAAAAAAAABgAAAAAAAAAmgpECESOz0CEkdFfz5nztcKAAAAQAAAAZ6tp53f1xEyxZ0kvghe7CQEAAAAA@rcn.com>
References:  <!~!UENERkVCMDkAAQACAAAAAAAAAAAAAAAAABgAAAAAAAAAmgpECESOz0CEkdFfz5nztcKAAAAQAAAAZ6tp53f1xEyxZ0kvghe7CQEAAAAA@rcn.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--ikeVEW9yuYc//A+q
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sun, Feb 15, 2004 at 10:20:12AM -0500, gerard-seibert@rcn.com wrote:

> Question # 1:
>=20
> When I type 'su' and subsequently type in my password, I am taken to the
> root. However, certain programs; i.e., 'portupgrade' will not run. If I t=
hen
> subsequently type 'su' I a, presented with a new prompt although no passw=
ord
> is requested. I can now run programs like 'portupgrade' without incident.=
 I
> am unable to find any documentation that states I should be running the '=
su'
> command twice. Can someone explain to me what is happening here? Is this
> normal. Exactly how many levels are there? I thought that there were only
> two: the log in level and root level. Is there a third level or is this s=
ome
> sort of fluke.

Yes.  You're right that there are only the two privilege levels --
root vs ordinary users.  What you're seeing is due to a different
effect.  The first time you su(1) you become root, but your shell
environment is not set up the way you expect.  Specifically you don't
have /usr/local/sbin on your $PATH, so when you type 'portupgrade' at
the prompt, the shell can't find the executable.  You should be able
to type '/usr/local/sbin/portupgrade' and have things work as
expected.

The second time you type su(1), it takes effect without asking for a
password, since the super user can become any other user without
giving one.  However, changing from root to root normally isn't
usually very productive.

Usually when you su(1), the shell environment is left the same except
for the USER, HOME and SHELL environment variables, which are reset
appropriately for the new userid.  However, settings in the target
login's .cshrc or .profile or .bashrc or whatever will take effect
exactly as for starting up any new shell.  There are some flags to
su(1) to modify that behaviour: '-l' (or just '-') says simulate a
full login by the target user, and '-m' does the opposite -- leaving
the original environment unmodified.

My guess is that the behaviour you are seeing is because either the
su(1) command is aliased to add in some other options, or that you
have something in root's shell initialization files which is causing
the effect.

On general principles, I'd recommend you to install and use sudo(8)
instead of su(1) -- it has much finer grained access controls, you
don't need to give out the root password in order to let people run
commands with root privilege and it logs everything done with it.
=20
> Question # 2:
>=20
> Second, while typing in search terms in Google, I came across this web si=
te
> - http://andrsn.stanford.edu/FreeBSD/newuser.html
>=20
> You will notice the entry about updating the database for the 'whereis' a=
nd
> 'locate' commands. I have read the manual on 'locate' and tried running t=
he
> files mentioned manually, but alias all I receive is an error message that
> the command does not exist. Again, I have no idea what I am doing
> incorrectly. Any assistance would be appreciated.

The database update will happen automatically, overnight, in the wee
small hours of Saturday morning.  So long as you leave you machine
running, that is.

You can manually update the 'locate' database by running (as root):

    # /etc/periodic/weekly/310.locate

and similarly for whereis:

    # /etc/periodic/weekly/320.whatis

Those should run without errors -- if you still have problems, please
feel free to e-mail here again, including the exact output of running
those commands.

	Cheers,

	Matthew

--=20
Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey         Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK

--ikeVEW9yuYc//A+q
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)

iD8DBQFAL5o8dtESqEQa7a0RAo0fAJsFnyZdcFXcN+Pb2ts6yS+egYDVbgCdFP5W
Q3zEmxFeUIwsHLy7ZNB006E=
=Ei3W
-----END PGP SIGNATURE-----

--ikeVEW9yuYc//A+q--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040215161140.GA86037>