45

I wanted to put my work files (code) in /usr/local/src, but I think it's already a folder that has some other semantic meaning.

What is that? Should I put source code there, or is there a better place?

Edit - I am the sole user and admin of the machine, and I don't want to use my home directory because it's on an NFS drive.

1

2 Answers 2

50

According to Linux FHS, /usr is the location where Distribution-based items are placed and /usr/local is the location where you'd place your own localized changes (/usr/local will be empty after a base install). So, for example, if you wanted to recompile an Ubuntu package from source, their package manager would place the source for package in /usr/src/{package dir}. If you downloaded a program not managed by your distribution and wanted to compile/install it, FHS dictates that you do that in /usr/local/src.

EDIT: Short answer, yes, put your code in /usr/local/src.

0
17

It depends on what you're doing with that source. If it's for reference, yes, that's a good place. /usr/local is reserved for software installed locally by the sysadmin. So, if you want to install software along with source files (for other programs to use or for people to look at), that's good.

It's not meant, however, to be a workspace. Since it is local, you can do whatever you want, of course, but this isn't designed to be the place to put your software development tree.

That should, really, be in a code repository (possibly in /srv/sourcerepo or something), and then developers would check out their own working copies into their home directories.

9
  • 1
    I second what mattdm says above. I usually use /usr/local/src as a good place for downloading third party source code (eg for patching and rebuilding packages), not my own source code, which as matt says, should be under /srv/... (though I usually use /srv/vcs/sourcerepo). And mirrored remotely, of course. Apr 7, 2011 at 18:44
  • 1
    @SherylHohman It doesn't really stand for anything (it's not an acronym) but we chose it to imply "service". See the FHS which says "/srv contains site-specific data which is served by this system".
    – mattdm
    Feb 7, 2019 at 19:46
  • 1
    @SherylHohman, taking from the folder description from the Linux Documentation Project, I would guess "srv" stands for "serve", "service" or something (anything?) related to the "serv-" root. Sep 30, 2020 at 6:25
  • 1
    @WaldirLeoncio Yeah, that's an older version of the same document I linked. I was involved in getting that added to the standard, and as I remember, it's not really that it stands for "server" or "service" but it's definitely meant as a mnemonic for that.
    – mattdm
    Oct 2, 2020 at 17:17
  • 2
    My answer was over a decade ago, but I think it still stands. /usr isn't meant to be a workspace. Check out and compile into your home directory. Build as a regular user. Install as root when done.
    – mattdm
    Feb 16, 2023 at 18:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .