linuxlab.io
Tutorials▾
  • Linux & networking
    File system, processes, TCP/IP, BGP and OSPF
    →
  • Terraform & IaC
    HCL, state, plan/apply on a LocalStack sandbox
    →
  • Git & GitHub
    Object model, plumbing, branching, GitHub Actions
    →
All tutorials →
PricingAboutSign inCreate account
/
Intro
Lessons
Footer
linuxlab-TutorialsPricingAboutPrivacy & cookies
Copyright © 2026 LinuxLab. All rights reserved.
linuxlab.io
Tutorials▾
  • Linux & networking
    File system, processes, TCP/IP, BGP and OSPF
    →
  • Terraform & IaC
    HCL, state, plan/apply on a LocalStack sandbox
    →
  • Git & GitHub
    Object model, plumbing, branching, GitHub Actions
    →
All tutorials →
PricingAboutSign inCreate account
/
  • Introduction
  • Chapters
  • How it works
  • Lessons
  • Knowledge base
  • Interview prep
home/git/kb/Open source/license

kb/oss ── Open source ── beginner

LICENSE: project license

The LICENSE file in the repository root defines the terms for using the code. Without a license, code is closed by default under copyright: you can view a public repository on GitHub (GitHub Terms of Service permit that), but you cannot copy, modify, or distribute it until the author explicitly grants permission. The most common licenses are MIT, Apache-2.0, and GPL.

view as markdownaka: license-file, oss-license

When you publish code on GitHub without a LICENSE file it remains legally "all rights reserved" for the author. Anyone can view the code in a browser and fork it within GitHub (GitHub Terms of Service permit this as a condition of using the platform), but without an explicit license the user has no right to:

  • copy it to their machine for use in their own project,
  • modify and distribute it,
  • embed it in their product.

This contradicts the intuition that "published on GitHub means open source." Code becomes open source when a license explicitly grants those permissions.

Every public project should have a LICENSE file in the root. Without one, the code is legally useless to anyone else.

Common licenses

MIT

The shortest and most permissive license. You can do almost anything: use it in commercial products, modify it, close your fork. The only requirement is to preserve the copyright notice.

MIT License
Copyright (c) 2026 Your Name
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software ...

Choose MIT when:

  • Your goal is maximum distribution.
  • You do not mind someone closing your code in a proprietary product.
  • Simplicity matters more than legal nuance.

Apache-2.0

Similar to MIT but longer, with two important additions:

  • Patent grant: explicitly licenses any patents related to the code to users.
  • NOTICE file: lets the author specify additional information that forks must preserve.

Choose Apache-2.0 when:

  • The project may carry patent risk.
  • Your target users are companies (legal teams tend to prefer Apache-2.0 over MIT because of the explicit patent grant).

GPL (v2, v3)

Copyleft: derivative works must also be under GPL. If you use GPL code in your product, your product becomes GPL too. This is a "viral" license, and that is by design.

Choose GPL when:

  • Your goal is to guarantee that the code stays open in all forks.
  • You are comfortable with commercial companies being unable to use it without disclosing their own code.

The Linux kernel is GPL v2. Most GNU tools are GPL v3.

LGPL (Lesser GPL)

GPL for libraries: you can link the library into a proprietary product without the "viral" effect (when linked dynamically). Modifications to the library itself must be kept open.

AGPL (Affero GPL)

GPL with a service-side clause: even a SaaS that uses AGPL code must disclose modifications to users of the service, not only to those who download the binary. This closes the "web service loophole."

BSD (2-clause, 3-clause)

Permissive, very similar to MIT. The difference is in the details: 3-clause prohibits using the author's name to endorse derivative products. In practice, BSD and MIT are interchangeable.

How to choose

  • Maximum distribution, do not care if someone closes the code → MIT.
  • Same, plus patent risk, plus corporate-friendly → Apache-2.0.
  • Want everything to stay open → GPL.
  • It is a web service, not a library → AGPL.
  • Not sure and do not want to research it → MIT (the default on GitHub).

The site https://choosealicense.com (by GitHub) walks you through a decision tree. Use it when you are uncertain.

Technical details

  • LICENSE file in the root. GitHub detects the license automatically when the file is named LICENSE or LICENSE.md (without prefixes such as MY-LICENSE).
  • Year and author. The MIT template requires a year and author name (Copyright (c) 2026 Your Name).
  • Header in source files. Some licenses (Apache-2.0) call for a short header in each source file. It is not strictly required, but it is the convention.
  • Changing a license retroactively is hard. If the repository has had contributors, their work legally remains under the original license; changing it requires consent from each of them. Choose carefully, because the decision is long-term.

Pitfalls

  • "No license" is legally all rights reserved. Do not say "I have no license, it's open source."
  • License compatibility matters. A GPL project cannot directly use Apache-2.0 code (there are nuances depending on the GPL version). BSD is compatible with MIT and Apache-2.0. Think about this when you add third-party code to your project.
    • A binary shipped without a LICENSE file is technically a violation of some licenses. Distribution generally implies delivering the LICENSE file alongside the binary.

§ см. также

  • contributing-mdCONTRIBUTING.mdA file in the repository root (or in `.github/`) that sets the rules for contributors: how to set up the environment, how to format commits, how to submit a PR. The clearer the CONTRIBUTING file, the fewer "how do I run this?" questions land in Issues.
  • fork-vs-cloneFork vs cloneClone is a local copy of a repository. Fork is a copy **on the server** under your account. In open source you usually fork first (gaining write access to your copy), then clone the fork (to work locally), and open a PR from the fork back to the original.
Footer
linuxlab-
Copyright © 2026 LinuxLab. All rights reserved.
Tutorials
Pricing
About
Privacy & cookies