0
0
Linux CLIscripting~5 mins

Why package managers install software in Linux CLI - Why It Works

Choose your learning style9 modes available
Introduction
Installing software manually can be slow and error-prone. Package managers automate this process by downloading, installing, and configuring software quickly and safely.
When you want to add a new program to your Linux system without manually downloading files.
When you need to update software to the latest version easily.
When you want to ensure all software dependencies are installed automatically.
When you want to remove software cleanly without leftover files.
When you want to keep your system secure by installing trusted software from official sources.
Commands
This command refreshes the list of available software and their versions from the repositories so your system knows what can be installed or updated.
Terminal
sudo apt update
Expected OutputExpected
Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease Get:2 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB] Get:3 http://archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB] Fetched 215 kB in 1s (300 kB/s) Reading package lists... Done
This command installs the 'curl' program, downloading it and any needed dependencies automatically.
Terminal
sudo apt install curl
Expected OutputExpected
Reading package lists... Done Building dependency tree Reading state information... Done The following NEW packages will be installed: curl 0 upgraded, 1 newly installed, 0 to remove and 5 not upgraded. Need to get 159 kB of archives. After this operation, 500 kB of additional disk space will be used. Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 curl amd64 7.68.0-1ubuntu2.7 [159 kB] Fetched 159 kB in 1s (200 kB/s) Selecting previously unselected package curl. (Reading database ... 210000 files and directories currently installed.) Preparing to unpack .../curl_7.68.0-1ubuntu2.7_amd64.deb ... Unpacking curl (7.68.0-1ubuntu2.7) ... Setting up curl (7.68.0-1ubuntu2.7) ... Processing triggers for man-db (2.9.1-1) ...
This command checks that 'curl' was installed correctly by showing its version information.
Terminal
curl --version
Expected OutputExpected
curl 7.68.0 (x86_64-pc-linux-gnu) libcurl/7.68.0 OpenSSL/1.1.1f zlib/1.2.11 libidn2/2.2.0 Release-Date: 2020-01-08 Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp Features: AsynchDNS IDN IPv6 Largefile NTLM NTLM_WB SSL TLS-SRP UnixSockets HTTPS-proxy
Key Concept

If you remember nothing else from this pattern, remember: package managers automate software installation by handling downloads, dependencies, and setup safely and quickly.

Common Mistakes
Trying to install software without updating the package list first.
The system may not know about the latest versions or new software, causing installation to fail or install old versions.
Always run 'sudo apt update' before installing new software.
Typing the software name incorrectly in the install command.
The package manager cannot find the software and will return an error.
Check the exact package name or use autocomplete features before running the install command.
Not using 'sudo' for installation commands.
Installing software requires administrative rights; without 'sudo', the command will fail due to permission errors.
Always prefix install commands with 'sudo' to run them with the needed permissions.
Summary
Run 'sudo apt update' to refresh the software list before installing.
Use 'sudo apt install software-name' to install new programs and their dependencies automatically.
Verify installation by running the software or checking its version.