Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 May 2020 16:39:24 +0200
From:      Polytropon <freebsd@edvax.de>
To:        Manish Jain <bourne.identity@hotmail.com>
Cc:        "@lbutlr" <kremels@kreme.com>, FreeBSD <freebsd-questions@freebsd.org>
Subject:   Re: On a serious note, what I'd change about FreeBSD hier(7)
Message-ID:  <20200513163924.1a65016c.freebsd@edvax.de>
In-Reply-To: <DB8PR06MB64429BBF3608B34B63D25168F6BF0@DB8PR06MB6442.eurprd06.prod.outlook.com>
References:  <83788746a7d8a802d8af4b582e00827166febd1a.camel@tom.com> <20200506172115.cb3b572b.freebsd@edvax.de> <CAEJNuHyB66K16JHFPcabfyoWoNT=GGFjFJ0wfqpDB27CYidnzA@mail.gmail.com> <20200506214540.247500820cf8701968ac01c9@sohara.org> <20200512190812259650810@bob.proulx.com> <DB8PR06MB64424C6B2603D902D7AC3C3AF6BF0@DB8PR06MB6442.eurprd06.prod.outlook.com> <6CA92BC4-DB17-4B6E-ACC9-9759BB6AC4F7@kreme.com> <DB8PR06MB64429BBF3608B34B63D25168F6BF0@DB8PR06MB6442.eurprd06.prod.outlook.com>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
On Wed, 13 May 2020 19:21:24 +0530, Manish Jain wrote:
> 
> 
> On 2020-05-13 17:21, @lbutlr wrote:
> > On 12 May 2020, at 23:33, Manish Jain <bourne.identity@hotmail.com> wrote:
> >> Perhaps you might like to remember another location : /opt
> >>
> >> That is entirely unused in the default config in FreeBSD, and I think /opt/bin makes a good location for the user's own software.
> > 
> > User software goes in ~/bin. Admin user’s software that is used by the system goes in /usr/local/bin.
> > 
> > I see no need for /opt/bin, what would you put there?
> > 
> > 
> 
> User software goes into ~/bin - that's right but with a caveat. What 
> goes into ~/bin is user-specific.
> 
> If I wrote a system-wide application intended to be available to all 
> users of this particular computer, /opt/bin would make a good choice.

Exactly! Whatever happens in ~/bin is local to the user, and
no other user can (per default) access software installed to
that place. A special case is /root/bin where the system
administrator can keep helper scripts that are not interesting
to anyone else.

If your program is not managed using the ports collection, but
you simply compile it yourself, putting it into /opt/bin is a
very convenient approach, especially if all users have a $PATH
that includes that non-standard executable directory.

The location /opt/bin is also very good for programs that have
non-standard naming and structure for their "non-managed"
installation. For example:

Program "foo":

	/opt/foo		-> directory where it's located
	/opt/foo/program/foo	-> the actual executable
	/opt/foo/assets/	-> various program components
	/opt/foo/temp/		-> a non-standard temporary storage

Program "bar":

	/opt/bar		-> again, program's base directory
	/opt/bar/labar.sh	-> the executable (a launcher script)
	/opt/bar/stuff.dat	-> program data
	/opt/bar/blah.txz	-> further program data
	/opt/bar/baz.zip	-> even more program data

For convenient "program starters":

	/opt/bin/foo@ -> /opt/foo/program/foo

	/opt/bin/bar@ -> /opt/bar/labar.sh

Now users can execute "foo" and "bar". In case a specific
"preparation" is needed, the symlinks can be replaced with shell
scripts that can, for example, set certain environment variables,
create required dummy files or even change permissions if needed;
they can also do "clean up" after the program terminated.

As you can see, /opt, as it is not "regulated", can deal with
"flat layouts", "custom trees" and anything just fine. :-)



> It's of course merely a suggestion, but does help to keep /usr/local/bin 
> cleanly reserved for what gets installed via pkg/ports.

Yes. That is the lesson of "man 7 hier". :-)


-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?20200513163924.1a65016c.freebsd>