As of late last year, when my work gave me a System76 Linux machine
I'm now officially 100% on Linux both at work and at home. I'm also a
programmer and on both my home and work machines I have a directory
under my $HOME
called dev
where I store all of my coding projects.
Most of the apps I install come from a package manager like apt
,
however from time to time I find the need to compile a project from
source. For example, I use Emacs as my coding editor and occasionally
there will be a new feature available on the main branch that is not
available in the current shipping package. Right now that is project
management that will be available in v28
but the current shipping
version (as of this writing) is v27
. If I want that feature then I
have to build Emacs myself. The question is, where do I put this
project because I don't really want it in my $HOME/dev
directory
with all my own projects.
Linux has developed a standard directory structure called the
FHS or Filesystem
Hierarchy Standard. In this standard they have defined a directory
/usr/local
with the following definition "The /usr/local hierarchy
is for use by the system administrator when installing software
locally.". Below that directory they have src
, and this directory
is designed for exactly this purpose. So if you're ever wondering
where to put 3rd party code that you want to build from source, or
maybe even some library that you found a bug in that you want to fork
and put up a PR, this is a great place to do it so it doesn't
interfere with your own projects. One thing I did do to make this a
little easier was to give ownership of this directory to my logged in
user.
sudo chown $USER:$USER /usr/local/src
Now you don't have to run sudo
every time you download source or run
a build command.
Tags: #linux
Categories: #technology