What's changed: Initial version (topic 2.04, subtopics 2.04.1–2.04.6)
4.1Building and Installing from Source with make
Learn the full workflow for building software from source instead of relying on package managers: fetching source with git clone, git tag -l, and git checkout; extracting with gzip/gunzip/bzip2/xz/tar/unzip; applying diffs with patch; detecting the environment with configure; and building/installing with make and make install.
Software not yet packaged by your distribution, or software you need to build with custom options, must be built from source by hand. For an operations engineer, mastering the whole sequence—fetching source, verifying it, and deploying it—is foundational professional knowledge.
4.1.1Fetching source and choosing a version
- git clone fetches the whole repository. To use a stable release, list tags with git tag -l and switch to a specific one with git checkout <tag>.
- Archives downloaded from a distribution site are extracted according to their compression: gzip/gunzip (.gz), bzip2 (.bz2), xz (.xz), tar (bundle extraction, e.g.
tar xzf), and unzip (.zip). - Vendor-supplied patch files are applied with patch (
patch -p1 < fix.patch), normally right after extracting the source and before running configure.
4.1.2From configure to make install
- configure (
./configure) detects the build environment (compiler, libraries, dependencies) and generates the Makefile.--prefix=sets the install location. - make compiles the source according to the generated Makefile. The following make install copies binaries, manuals, and other files to the install location (default /usr/local, etc.).
- The classic sequence is
./configure && make && make install. If configure detects a missing dependency, it stops with an error that must be resolved before running make.
The most common questions test order: configure generates the Makefile, make compiles, make install deploys, and patch is applied after extraction but before building; also git tag -l to list tags, then git checkout to switch. Matching compression extensions to tools (.gz=gzip/gunzip, .bz2=bzip2, .xz=xz) is another standard identification question.
A concrete scenario clarifies the sequence. Right after git clone, the working tree is often the latest in-development commit, so first check release tags with git tag -l (e.g. v2.4.1) and explicitly switch with git checkout v2.4.1. For a vendor-distributed tarball, pick the extraction flags matching the compression: tar xzf for .tar.gz, tar xJf for .tar.xz. After extracting, if a patch file fixing a known issue is supplied, cd into the source directory and apply it with patch -p1 < xxx.patch before running configure. Because configure checks for compilers and dependency libraries to produce a Makefile tailored to the environment, a missing-dependency error here must be resolved before proceeding to make. The final make install typically needs root privileges and deploys outside the distribution's package management (e.g. into /usr/local/bin), which is an operational tradeoff—future updates and uninstalls become more manual.
| Compression | Extraction command | Note |
|---|---|---|
| .gz | gzip -d / gunzip | With tar: tar xzf |
| .bz2 | bzip2 -d | With tar: tar xjf |
| .xz | xz -d | With tar: tar xJf |
| .zip | unzip | A separate format from tar |
Trap: "make deploys files to the install location" is wrong—make compiles, make install deploys. "patch is applied after configure" is also wrong—it is normally applied right after extraction, before configure. "git checkout lists tags" is wrong too—listing tags is the job of git tag -l.
4.1.3Section summary
- Fetch with git clone / git tag -l / git checkout; extract per compression type with gzip, bzip2, xz, tar, unzip
- Order: patch → configure (generates Makefile) → make (compiles) → make install (deploys)
Sign in to track progress — Log in.
Quick check
(just a quick review)Q1. After cloning a Git repository, you want to switch to the source at release tag v2.4.1. Which command pair is correct for checking and then switching?
Q2. You need to extract app-1.0.tar.xz, apply fix.patch (a known-issue fix), then build. What is the correct order of operations?
Q3. Running ./configure && make && make install stops during the configure stage with a missing-library error. What should you do next?
Keep track of your progress
The full study guide is free to read. Sign up free to practice with the question bank, track what you have read, review your mistakes, and highlight passages.

