Standard location for holding software source files

Whenever you ask yourself something like this, check out the Filesystem Hierarchy Standard (FHS).There, you will find the following entry:

usr/src : Source code (optional)


Source code may be placed in this subdirectory, only for reference purposes

So you can put your source files in subdirectories of /usr/src. That said, this is an optional directory so you can really keep them wherever you like. Source code is not relevant after you've compiled it into an executable so the system will never require the source of something to be accessible at a specific location.

In conclusion: /usr/src is a pretty standard location but feel free to choose your own if you prefer.

/usr/local/src is a safe place to keep source code, and build it too. The FHS says:

Directory   Description  
src         Local source code

and also

The /usr/local hierarchy is for use by the system administrator when installing software locally. It needs to be safe from being overwritten when the system software is updated.

It's not clear what "Local source code" means, but it's clear the system isn't going to try to place anything in /usr/local/src, unlike /usr/src, so there seems to be little downside to putting code there.

In fact, I have mine on a separate filesystem:

Filesystem                    Size  Used Avail Use% Mounted on
/dev/mapper/data-local_src     79G   46G   30G  61% /usr/local/src

Note: at least on Debian, your user needs to be added to the staff group in order to write to /usr/local.

If by "standard" you mean conventional, then the place to unpack and build source code is your home directory. Such files are expected to be transient, deleted when you are done, or kept if you like, organised however you please. Your home directory is your area to play with all this kind of stuff.

If you do wish to keep them afterwards, for reference, the "Filesystem Hierarchy Standard" recommends /usr/src. However, this is a guide not a law; and, if you were to get into this habit then venture onto a non-Linux system, you are liable to cause trouble by following it. For example, on a BSD system, base system sources are kept there and you really don't want to be messing with those. Even on Linux you may run the risk of mingling with any source stored by package managers, which is not desirable.

I would recommend avoiding /usr/src overall. There's no obvious benefit to keeping anything there at all, and potential risk if you confuse its intended meaning.