0
0
Linux CLIscripting~10 mins

Building from source basics in Linux CLI - Commands & Configuration

Choose your learning style9 modes available
Introduction
Sometimes software is not available as a ready-made package. Building from source means compiling the program yourself from its original code. This lets you customize or use the latest version.
When you want to install a program that is not in your system's package manager.
When you need a newer version of software than what your system offers.
When you want to customize software features by changing its source code.
When you want to learn how software is built and installed on Linux.
When troubleshooting software issues that might be fixed by rebuilding.
Commands
This command extracts the compressed source code archive so you can access the files needed to build the software.
Terminal
tar -xzf example-software-1.0.tar.gz
Expected OutputExpected
No output (command runs silently)
-xzf - Extract a gzip compressed tar archive
Change directory into the extracted source code folder to prepare for building.
Terminal
cd example-software-1.0
Expected OutputExpected
No output (command runs silently)
This script checks your system for required tools and libraries and prepares the build configuration.
Terminal
./configure
Expected OutputExpected
checking for gcc... gcc checking for make... make checking for required libraries... found Configuration complete. Ready to build.
This command compiles the source code into executable programs using the instructions from the configure step.
Terminal
make
Expected OutputExpected
gcc -o example example.c make: Nothing to be done for 'all'.
This installs the compiled program into system directories so you can run it from anywhere.
Terminal
sudo make install
Expected OutputExpected
Installing example to /usr/local/bin Installation complete.
sudo - Run the install command with administrator rights
Key Concept

If you remember nothing else from this pattern, remember: building from source means extracting, configuring, compiling, and installing step-by-step.

Common Mistakes
Skipping the ./configure step before running make
The build system won't know your system setup and may fail or build incorrectly.
Always run ./configure first to prepare the build environment.
Trying to install without sudo permissions
Installing to system directories requires admin rights and will fail without them.
Use sudo before make install to get the necessary permissions.
Not extracting the source archive before building
You cannot build from a compressed archive; files must be extracted first.
Use tar -xzf to extract the source code before building.
Summary
Extract the source code archive with tar -xzf.
Run ./configure to prepare the build system for your environment.
Use make to compile the source code into programs.
Run sudo make install to copy the programs to system directories.