0
0
Linux CLIscripting~10 mins

Building from source basics in Linux CLI - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Building from source basics
Download source code
Extract source files
Configure build options
Compile source code
Install compiled program
Clean up build files
DONE
This flow shows the main steps to build a program from source code on Linux.
Execution Sample
Linux CLI
wget http://example.com/app.tar.gz

tar -xzf app.tar.gz

cd app

./configure

make

sudo make install

make clean
This script downloads, extracts, configures, compiles, installs, and cleans up a program from source.
Execution Table
StepCommandActionResult/Output
1wget http://example.com/app.tar.gzDownload source archiveapp.tar.gz downloaded
2tar -xzf app.tar.gzExtract filesSource files extracted to ./app
3cd appChange directoryNow inside source folder ./app
4./configurePrepare buildChecks system, creates Makefile
5makeCompile sourceBuilds executable files
6sudo make installInstall programCopies files to system folders
7make cleanClean build filesRemoves temporary build files
8-EndBuild and install complete
💡 All steps completed successfully, program built and installed.
Variable Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4After Step 5After Step 6After Step 7Final
Current Directory/home/user/home/user/home/user/home/user/app/home/user/app/home/user/app/home/user/app/home/user/app/home/user/app
Source ArchiveNoneapp.tar.gzapp.tar.gzapp.tar.gzapp.tar.gzapp.tar.gzapp.tar.gzapp.tar.gzapp.tar.gz
Build FilesNoneNoneExtractedExtractedConfiguredCompiledCompiledCleanedCleaned
Installed ProgramNoNoNoNoNoNoYesYesYes
Key Moments - 3 Insights
Why do we run './configure' before 'make'?
The './configure' step checks your system and creates the Makefile that 'make' uses to compile. Without it, 'make' won't know how to build the program. See execution_table step 4 and 5.
What happens if we skip 'sudo make install'?
Skipping 'sudo make install' means the program is compiled but not copied to system folders, so you can't run it globally. It stays only in the build folder. See execution_table step 6.
Why do we use 'make clean' at the end?
'make clean' removes temporary build files to free space and keep the folder tidy. It does not remove the installed program. See execution_table step 7.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the result of running 'tar -xzf app.tar.gz'?
ASource files extracted to ./app
Bapp.tar.gz downloaded
CBuilds executable files
DCopies files to system folders
💡 Hint
Check execution_table row 2 under Result/Output column.
At which step does the program get installed on the system?
AStep 4
BStep 5
CStep 6
DStep 7
💡 Hint
Look at execution_table step 6 and its Action and Result.
If we skip './configure', what will likely happen when running 'make'?
ACompilation will succeed without issues
BMakefile will be missing or incorrect, causing errors
CProgram will install automatically
DSource files will not extract
💡 Hint
Refer to key_moments about the role of './configure' before 'make'.
Concept Snapshot
Building from source involves these steps:
1. Download source code archive
2. Extract files with tar
3. Run './configure' to prepare build
4. Compile with 'make'
5. Install with 'sudo make install'
6. Clean build files with 'make clean'
Full Transcript
Building from source means creating a program from its original code. First, you download the source archive file. Then you extract it to get the source files. Next, you run './configure' to check your system and prepare the build instructions. After that, you compile the code using 'make'. Once compiled, you install the program with 'sudo make install' so it can be used system-wide. Finally, you can clean up temporary build files with 'make clean'. Each step must be done in order for the build to succeed.