Chapter 3: Linux Basic Commands
3.7 Package managers
Think of a package manager like the Play Store on your mobile – you ask for an app and it downloads it from a trusted store, along with all the dependencies it needs. But technically, a package manager uses configured repositories, verifies repository information or packages according to its trust model, and resolves dependencies. Look, the commands differ a little by distribution:
पॅकेज मॅनेजरला मोबाइलमधल्या Play Store सारखं समजा – ॲप मागितलं की तो trusted स्टोअरमधून डाउनलोड करतो, आणि त्याला लागणारे सगळे dependencies सुद्धा. पण टेक्निकली, पॅकेज मॅनेजर configured repositories वापरतो, त्याच्या trust model प्रमाणे माहिती किंवा packages तपासतो आणि dependencies resolve करतो. बघा, कमांड्स डिस्ट्रिब्युशनप्रमाणे थोड्या वेगळ्या आहेत:
पैकेज मैनेजर को मोबाइल के Play Store जैसा समझो – ऐप माँगा तो वो trusted स्टोर से डाउनलोड करता है, और उसके लिए ज़रूरी सारी dependencies भी. लेकिन टेक्निकली, पैकेज मैनेजर configured repositories इस्तेमाल करता है, अपने trust model के हिसाब से जानकारी या packages की जाँच करता है और dependencies resolve करता है. देखो, कमांड्स डिस्ट्रीब्यूशन के हिसाब से थोड़ी अलग हैं:
A package manager downloads software from trusted repositories, installs dependencies automatically, and handles updates.
| Task | Ubuntu or Debian | Amazon Linux 2023 |
|---|---|---|
| Refresh package metadata | sudo apt update | Refreshes as needed. dnf makecache explicitly builds the metadata cache. |
| Plan a package upgrade | apt-get -s upgrade previews the actions. | dnf check-update reports candidates in its configured scope. Choose an approved repository release before a change. |
| Find package information | apt-cache policy tree | dnf info tree |
| Check an installed package | dpkg-query -W tree | rpm -q tree |
| Find an installed file's owner | dpkg-query -S /usr/bin/tree | rpm -qf /usr/bin/tree |
| Review an authorized installation | sudo apt install tree | sudo dnf install tree |
| Clear downloaded package archives | sudo apt clean | sudo dnf clean packages |
| Package file format | .deb | .rpm |
Older Amazon Linux 2 guides can refer to YUM and Amazon Linux Extras. Amazon Linux 2023 uses DNF and its versioned repositories. Check the package catalogue for the intended release before applying instructions from another distribution.
yum or dnf? Kalji karu naka
Amazon Linux 2023 documents dnf as its package manager. The yum name points to DNF on that release. Older YUM implementations can differ, so check the distribution and release before reusing a command from another guide.
Check before adding a repository
Verify that the repository publisher supports the exact distribution and release you are using. A repository for another RPM-based distribution can offer incompatible packages. Use your learning environment’s approved repositories.
Ravindra Bagale's Tip
Many students type apt install on Amazon Linux and see command not found. First check cat /etc/os-release. Amazon Linux 2023 uses DNF. Ubuntu and Debian use APT. Then verify the exact package and available source.
Ravindra Bagale's Tip – मराठी
Amazon Linux वर apt install चालत नसेल तर आधी cat /etc/os-release बघा. Amazon Linux 2023 साठी dnf, Ubuntu आणि Debian साठी apt वापरतात. त्यानंतर package आणि repository तपासा.
Ravindra Bagale's Tip – हिंदी
Amazon Linux पर apt install नहीं चलता तो पहले cat /etc/os-release देखो. Amazon Linux 2023 में dnf, Ubuntu और Debian में apt इस्तेमाल होता है. फिर package और repository की जाँच करो.
Lab
Chala, check whether your existing Amazon Linux 2023 lab has the tree package and whether your current shell finds the program. These queries do not install or remove it.
rpm -q tree
command -v tree
dnf info tree
Run the lines individually. The first asks the installed database, the second checks shell path resolution and the third can consult available package metadata. Record where the answers differ before deciding whether an installation is needed.
Got it? First identify the OS, then choose the package manager. Now let's move on to processes.
समजलं का? आधी OS ओळखा, मग पॅकेज मॅनेजर निवडा. आता पुढे जाऊया प्रोसेसेसकडे.
समझ आया? पहले OS पहचानो, फिर पैकेज मैनेजर चुनो. अब आगे चलते हैं प्रोसेसेस की तरफ़.
Start with the program your task needs
Mauli Dairy's support team needs to include a readable directory layout in its handover notes. A colleague uses the tree program on an Ubuntu workstation. It shows folders and their contents in a nested outline. Asha tries the same program on an Amazon Linux 2023 learning instance and sees tree: command not found. This could mean that the program is absent, that her shell cannot find it on its search path, or that the procedure names a different command from the one installed. Someone sends her a download page. Before she tries it, she wants to find out what the operating system already provides and which source she is meant to use.
When a distribution manages software, it provides a way to describe the program, its version, the other components it requires and the files that belong to it. That description and the distributable files are collected into a package. A package might contain an executable, documentation, configuration templates or library files. A library is reusable code that programs can call. One human-facing program can be assembled from several packages so that different programs share a library or so that optional features can be installed independently.
A package manager receives a request such as “prepare the tree package for this system.” It identifies a candidate based on configured sources, finds compatible requirements, shows the planned changes and, when authorized, installs the files and records the installed version. Later queries can show which package owns a path. An update can replace packages with newer compatible versions. For this lesson the first goal is smaller. We will establish the identity of the machine, distinguish its package database from the program the shell can run, and read an installation plan before changing anything.
This is one of the skills you will use when learning AWS server administration. You can get the reasoning right without starting an EC2 instance. Use an existing Linux learning environment if you have one. There are sample outputs for readers on another operating system or on a host without a usable package index. The core lab does not install or remove software. An optional practice installation belongs only on a disposable Linux lab with authorization for package changes. The worked examples use a directory listing utility so that the main topic stays on packages rather than service configuration.
Identify the distribution, release and architecture first
The Linux kernel is the part of the operating system that manages basic resources and enforces many process and filesystem rules. A distribution combines that kernel with selected software, configuration, packaging tools and a release process. Amazon Linux 2023 and Ubuntu both run Linux. They use different package ecosystems and make different promises about which packages are delivered together. A command from one environment can be missing from the other even though the basic navigation commands look the same.
if [ -r /etc/os-release ]; then
grep -E '^(PRETTY_NAME|ID|VERSION_ID)=' /etc/os-release
else
printf '%s\n' 'Use the sample Linux release record for this exercise.'
fi
uname -m
command -v dnf
command -v apt-get
PRETTY_NAME="Amazon Linux 2023"
ID="amzn"
VERSION_ID="2023"
aarch64
/usr/bin/dnf
The first part prints three operating system fields if the standard release record is available. You may see additional wording on your system. Read the whole release value rather than guessing from a prompt label. The architecture line describes the machine's reported hardware execution context. On a normal Linux host, aarch64 identifies a 64-bit Arm architecture and x86_64 is a familiar alternative. Package managers choose compatible packages based on their own architecture and configuration. If you are reading instructions for a prebuilt binary, check the supported architecture before expecting it to run.
command -v asks the current shell what it would use for a command name. In the sample, a DNF command exists. The APT lookup produces no line because that command is absent. An absent lookup can return a nonzero status, so run each line separately if your shell is configured to stop at that point. On Ubuntu the APT tool is the usual result. On Amazon Linux 2023, use DNF as the canonical tool. AWS documents a yum compatibility entry for that release. Older Amazon Linux 2 material uses YUM. A guide that says “use YUM everywhere on Linux” hides the release and configuration decisions that actually determine what is available.
APT and DNF are higher-level package managers. Debian-family package files commonly end in .deb. RPM-family package files commonly end in .rpm. Commands such as dpkg-query and rpm -q can ask the local package database about installed packages directly. The distribution also decides package naming. For instance, two distributions may supply an equivalent web server under different familiar package names. Search or query the intended repository for the release before translating the command from a guide.
Understand the catalogue, download and installed record
A repository is a configured source of packages and the catalogue that describes them. The description helps the package manager find a candidate. It can include versions, architecture, checksums, dependencies and paths. Your package manager can save a local copy of this catalogue to avoid fetching it before every query. This saved information is commonly called metadata or a package index. If the index is stale, a package might show an older candidate or no candidate even though the repository now has it. If the machine cannot reach the source, a cached answer may still appear, depending on the tool and policy. Record the age and origin of the answer.
There are three different states to name when you are troubleshooting. First, the repository metadata may advertise a package. This tells you a candidate can be considered under the current configuration. Second, a package file may be downloaded or temporarily cached. Such a download does not itself put the program into normal use. Third, the installed package database may record a version as installed. That last record establishes what the distribution believes it put on this system. The actual path and ability to execute it are meaningful follow-up checks.
APT's usual refresh command, apt update, fetches metadata about available packages. The command requires appropriate access to write the system index. The separate apt upgrade requests changes to installed packages and shows a plan. DNF can refresh metadata when it needs to and offers dnf makecache to populate usable metadata. DNF installation and upgrade commands plan changes to installed packages. Read the operation in full. The word update can mean a metadata refresh in one package manager and an alias for a package upgrade in another. Use the help for the exact tool your host uses.
A common mistake is using the word “latest” without specifying the pool of candidates. The output might mean the most suitable package among your enabled repositories, policy and supported architectures. It can differ between two releases that are both supported. It can also differ between two machines on different repository versions of the same distribution. Projects often publish upstream source code more frequently than a distribution packages it. A distribution can incorporate a fix into its existing package version series. Consult the distribution's package version and advisory rather than assuming a version label proves a particular security fix is absent.
Think of the original support question. Asha wants to know which source supplies the program when it is not already in the shell's path. On an APT family system, apt-cache policy tree can show installed and candidate details. On a DNF system, dnf info tree can show matching package information from the enabled repositories and installed record. Both answers come with context. If a tool has no index or its repository is unreachable, find that reason before saying “this distribution doesn't have it.”
Read a transaction as a plan for several packages
A dependency names something the requested software requires. It can refer to a particular package version range or to a capability that one of several packages can supply. Suppose a program needs a library to handle compressed reports. If a compatible library is already installed, the manager can use it. If not, the plan may include installing that library. An existing package on the system can also require another version. The package manager attempts to find a compatible arrangement under the distribution's rules. It reports a problem if it cannot satisfy the requirements with the available candidates.
The package responsible for the main program and the library are separate items in the installed database. This allows coordinated updates and lets several programs call into a common library. It also explains why a transaction can modify more than one line even when you typed one package name. A typical summary separates installations, upgrades and removals. Compare every category. An unexpected removal may break something you expected to keep. Ask what initiated that proposed change before accepting it. Decline an unfamiliar plan and bring the summary to the owner of the environment.
For a concrete example, imagine a pretend utility called catalog-report and a pretend library called report-format. The planned transaction says the application will be installed and the library will be updated. A second existing tool still requires an earlier library range. If both tools can work with the proposed library release, the plan might be valid. If they cannot, the tool might report unsatisfied dependencies or offer a different arrangement according to policy. The first safe action is to record the exact requested package, version and conflict. Deleting files manually cannot fix the dependency relationship stored in the package database.
Some packages supply a recommended component in addition to a strict dependency. The distinction and defaults depend on the package ecosystem and local settings. A smaller training utility can have a one-line installation plan because the dependencies are already present. On another image the same utility can add dependencies. Begin with the actual transaction summary printed by your environment, then explain why the count might differ. The examples here show the shape of the plan. Your exact package versions, sizes and row order are expected to vary.
Package managers commonly ask for confirmation before an install, removal or upgrade. You may see command examples that include -y, which generally accepts ordinary confirmation prompts automatically. Seeing the summary is useful in a learner's session. Read it before confirming, especially if a dependency you did not anticipate will change. Some different kinds of verification or policy error can still stop a command. Auto-confirmation does not make a plan appropriate for your system. It also does not guarantee a successful transaction if downloads, signatures, disk space or package scripts fail.
Compare installed packages, command paths and file owners
Two learners ask whether tree is installed. One sees an installed package version. The other successfully runs the command but the package query reports that the distribution package is absent. Both can be telling the truth. An executable can come from a local installation, a different package, a shell function or another software manager. A package can also be installed while the shell fails to find its executable due to a restrictive search path. Use two independent checks before diagnosing it.
| Question | APT and dpkg family | DNF and RPM family |
|---|---|---|
| Which candidate is available? | apt-cache policy tree | dnf info tree |
| Is this distribution package present? | dpkg-query -W tree | rpm -q tree |
| Which installed package records this file? | dpkg-query -S /usr/bin/tree | rpm -qf /usr/bin/tree |
| What will this shell run? | command -v tree | command -v tree |
When the exact installation state matters in the Debian package database, include its full recorded status. A package whose executable was removed can leave configuration behind. A query showing that a record exists is weaker evidence than a query reporting install ok installed. The custom format below prints status and version from that record. It is a quoted format string interpreted by dpkg-query. Single quotes keep the shell from attempting to expand the dollar signs. This example has no network operation and does not change packages.
dpkg-query -W -f='${Status} ${Version}\n' tree
install ok installed 2.1.0-1
On the RPM family, rpm -q tree can report the installed version and architecture or say the package is absent. Query ownership using the exact executable path you found. If it lives under a location such as /usr/local/bin, the file ownership query may report that no distribution package owns this file. That observation points to investigating the other installation source. Also compare any alternate paths if your shell has an alias or function that serves the same command name. A useful report includes the release, package status, actual command resolution and what you expected the program to do.
Installed file ownership and repository search answer different questions. If you are missing a command, a query against available repository file metadata, such as DNF's provides search, can help identify a package that supplies a path. If the executable is already on disk, an installed ownership query is the right starting point. System paths can be related by symlinks or by merged directory layouts. If a file is not attributed under the path you typed, check the actual file and package paths. A missing ownership result, on its own, is no proof that the operating system is broken.
Check where software comes from before authorizing installation
Installing a system package can put executable code and configuration on the machine, and may run package-supplied scripts. For example, a service package can add service definitions or create directories as part of its installation. That makes the repository part of the trust decision. A properly configured distribution repository has a way for the package manager to verify information and downloads against the publisher it is configured to trust. If you choose a source, you are also choosing which publisher is in that decision.
APT's archive verification normally uses a signature on repository release metadata. The signed metadata leads through checksums to the package files. That chain lets APT check that the retrieved file agrees with the authenticated catalogue. It is different from a separate signature check on each downloaded Debian package. An RPM-based setup with DNF can enforce package signature checking and has separate options for checking repository metadata signatures. The details depend on the package manager and repository configuration. Learn the trust mechanism on your distribution rather than assuming all package formats are verified in the same way.
A failed authenticity check is a reason to pause. Preserve the error and the repository name, check the release against the publisher's documentation and consult whoever maintains those sources. A server time problem can make some validity checks fail, and an old repository record can point to a removed release. A changed signing key can be legitimate if it is documented by the publisher through an approved channel. Confirm that explanation before updating trust configuration. A successful download alone says the bytes arrived. It does not establish that the configured publisher supplied them.
Joining another repository also changes candidate selection. A new source can contain packages with names that overlap existing packages. Dependencies may then draw from more sources than you originally expected. A list of instructions from a forum may target a different major release or CPU type. Identify the publisher and documented support for your exact distribution. Avoid adding a third-party repository just because a package was missing from an older local index. If the assigned hospital, school or company environment has an approved source, use its package procedure and ask who owns repository changes.
The distinction matters with Amazon Linux 2023 and instructions written for another RPM distribution. RPM describes a package ecosystem, so the extension can match even if libraries, naming and signing policies differ. A repository intended for an Enterprise Linux release should not be assumed compatible with Amazon Linux 2023. Similarly, a package download that was built for another Ubuntu release may require a version of a library you do not have. Begin with the distribution's supported evidence and consider an alternate source only if you can explain its support and trust conditions.
Interpret a pinned Amazon Linux 2023 repository version
Two Amazon Linux 2023 training instances were created weeks apart. Asha runs a package check on both and sees different versions of the same library. Their operating system family and major release match. The package source is versioned, and the two instances can be locked to different versions of that source. Amazon Linux 2023 uses this approach by default so that environments built from the same release can reproduce package choices. It also means that an apparently empty update list can refer to the repository version in use rather than all more recent releases.
rpm -q system-release --qf '%{VERSION}\n'
dnf check-release-update
Run these on an Amazon Linux 2023 learning instance where the commands are available and its package sources can be reached. The first command reads the installed release package value. The second, when the release notification plugin is available, checks whether newer repository versions are published. Some minimal container images omit that plugin. A message that there is no such command is evidence about that environment's tooling. It does not answer whether AWS published a newer repository. Consult the distribution release notes or the documented administration workflow.
Checking the currently configured repository with DNF can show packages available within that version. To inspect another release's candidates, AWS documents specifying the intended release version in the query. Choose a version from the current official release notes and follow the instructions for a learning or managed maintenance environment. A newer repository available for selection and an installed system already updated to it are two separate facts. The first belongs in the review plan. The second requires verification after an approved change.
dnf check-update uses exit status 100 when updates are available, zero when no updates are available and other nonzero statuses for problems according to the installed tool. This matters if you turn a manual check into an automated report. A simple “nonzero means failure” condition would accidentally mark the useful case of available updates as a tool error. Run the check in a confirmed environment, preserve its status and interpret it. On a pinned instance the scope of this result still depends on the specified or configured release.
Before a planned fleet update, identify the set of instances or images involved and the release being targeted. A system update can replace files which a running service has already loaded. Depending on the packages, the operating system and local configuration, services may restart when the package manager changes them or may require a planned restart. A kernel change can require a reboot to run the new kernel. Record the maintenance plan and verify the actual application after the work. An installed package listing tells you the files have been installed. It does not by itself tell you which running instance of a service is using them.
Use a package query to decide your next step
Make a small observation record with fields for operating system and release, architecture, installed state, available candidate and shell resolution. For this lab, the program's only job is to display a practice folder tree. It does not need network access or administrative privileges to run after it is installed. If you cannot run these commands on a matching Linux learning environment, compare the sample outputs below and fill in the record from them.
Run the distribution identification commands above. Choose the branch that matches the package ecosystem on your learning host. If your terminal is currently on macOS or another platform outside these two branches, use the printed examples. An SSH session on a remote machine and the local terminal on your laptop can use different managers.
Ask whether the shell can find the program by running
command -v tree. Write down the path if it appears. Save an empty result as “shell did not resolve this command in the current environment.” You can compare that observation with the installed query instead of treating it as the answer to both questions.Use a package query appropriate to the chosen distribution. Start with the local installed database. Then check the candidate if the metadata is initialized and the host is allowed to reach the package sources. Repository queries can refresh cache metadata and use the network. You can do the rest of this exercise from the sample output if the system must stay offline.
# In an Ubuntu or Debian learning environment
dpkg-query -W -f='${Status} ${Version}\n' tree
apt-cache policy tree
apt-get -s install tree
# In an Amazon Linux 2023 learning environment
rpm -q tree
dnf info tree
The APT simulation flag asks APT to show the actions it would plan without performing the install. It can refuse if necessary metadata is missing or detect a dependency issue. The preview is based on the current view of the system. Other activity could change that state before a real transaction. The DNF branch above previews package information, not a full transaction. On a disposable machine where package commands are authorized, DNF's --assumeno option answers no to confirmation questions if you choose to preview an installation plan through the documented DNF workflow. It can still read or refresh metadata and can report a nonzero result when the transaction is declined.
Suppose the APT output shows Installed: (none) and a candidate version alongside a configured release source. The simulation displays one new named package, no upgrade and no removal. Your observation record can say “not installed from the distribution, candidate visible in the configured source, simulated plan installs just the requested package on this lab.” If the simulation reports no candidate, check the OS release and the configured index before you plan a change. If it proposes removing a package the lab uses elsewhere, stop at the review step and understand that dependency first.
In a second scenario the RPM query prints an installed package version and the shell lists /usr/bin/tree. Check the connection with rpm -qf /usr/bin/tree if that is the actual path shown. If the owning package resolves to the installed tree package, the package record and the executable agree. Run tree --version for a quick program check if you want to confirm it is working. It should print a version line. It is possible to get a successful version line from another executable farther ahead in the search path. Attach the resolved path to your evidence.
Here is a third case to reason through. The RPM query says the distribution package is absent. The shell finds /usr/local/bin/tree, and the RPM ownership query reports no installed package owns that path. One reasonable conclusion is that it may have been installed through another workflow. Check who maintains the local executable before installing a second copy. If the machine's path order resolves the local executable first, installing a distribution package may leave the same executable in use. A good answer identifies the current command and proposes a check with the system owner rather than removing the local file by hand.
Read the first diagnostic that explains a failed package request
Consider three students who all report “install didn't work.” One learner gets a shell error before the package manager begins. Another reaches the package manager, which finds no candidate. A third sees several packages listed, then gets a message that a repository could not be verified. A single suggestion to rerun the command would ignore what each system has told us. Look for the first meaningful error and identify the stage at which it appeared. You can often isolate that stage without making another change.
When the shell cannot find the package manager itself, run the distribution check and resolve the intended command path. A Linux shell connected to another host may use a different tool from a terminal tab on your own machine. On a minimal image the standard tool may not be installed, or an alternate compatible command may be provided. Use a learning environment intended for the instructions. Keep the complete command and the observed platform together in your lab note. A correct package name will have no effect on a shell that cannot launch the package manager.
When the manager tells you there is no candidate, check the exact spelling and the distribution release. The source records and metadata may be absent, expired, unreachable or scoped to a different version. In a cache-only DNF query, the option -C uses the available cache even when it is expired. If there is no cached record it can fail or have less information. That result does not answer what is on the remote repository today. A refresh, if the lab permits it, can distinguish a stale local view from a genuinely unavailable candidate. If a configured source rejects authentication, preserve the verification error instead of substituting an unapproved download.
Another learner receives a package database lock message. Distribution tools can coordinate changes with another process, such as a scheduled background update or a colleague's transaction. Find out whether an authorized operation is already active and wait for the owner of that operation. Deleting a lock indicator by hand cannot make concurrent database writes coordinated. In a managed environment, send the exact error and time to whoever owns package maintenance. If an installation began and stopped partway through, check its documented recovery procedure on that distribution. The software state may already differ from your initial observation.
Make the troubleshooting test concrete. Read this imaginary support note. “Ubuntu training VM, Arm architecture. Shell resolved the APT tool. The installed query showed no record for the package. The candidate query had no candidate. The earlier index refresh reported failure for the configured repository.” The next step is to inspect that repository access or configuration under the approved setup. If instead the candidate and transaction appeared and the disk was full while unpacking, the evidence would point to a later stage. A teammate should be able to find the next owning system or process from your note without guessing what command they should repeat.
Review and verify an approved change in a disposable lab
If you are assigned a disposable Linux system for actual package practice, continue from the observations rather than starting over. First confirm that the intended package was absent from its installed database and that the executable was not already resolved. Confirm the candidate and repository expected by the exercise. If the package was present at the start, keep the initial state. Practise the read-only queries and skip removal. These choices let a colleague reproduce your work without accidentally removing software they had before the exercise.
On an APT system with stale metadata, use the approved index refresh for the learning host. On DNF, use the configured release and let the normal metadata policy apply. If a source fails verification or the expected candidate is missing, preserve the error before attempting any installation. Do not change providers just to avoid an error message.
Choose the package manager's single install command from this block for the assigned host. Read the summary before confirming. For this exercise the plan should install the requested utility and at most its reviewed requirements. Decline the action if it includes unapproved changes.
# Ubuntu or Debian
sudo apt install tree
# Amazon Linux 2023
sudo dnf install tree
After installation, query package status again and compare it with the before value. Resolve the command, determine file ownership for that path and run the version check. A new installed record plus the expected program path and version is stronger evidence than a line saying “complete.” If the executable is missing or still points to an earlier local install, examine the plan and the command path before trying to install anything else. Save the concise package version and the operating system release in the lab log.
Cleanup depends on the original state and the sandbox. If you created a disposable system specifically for the exercise, the lab owner can retire or restore the environment according to its setup. If the exercise explicitly requires removing the one utility that you installed on a lab you keep, use the matching manager's remove operation and read its removal plan before accepting. Check that it includes only the intended changes and that you can compare the resulting installed record to your original observation. A removed package can leave data or configuration depending on the operation and package. DNF can consider unneeded installed dependencies when removing a package. APT distinguishes ordinary removal, purging package configuration and removing automatically installed packages that are no longer needed.
These are different actions from clearing downloaded package archives or refreshing metadata. Clearing a download cache can save disk space or require a future fetch. Removing packages changes the software state. Purging package configuration can discard settings. Updating everything is a different task from cleaning up a demonstration. After any allowed cleanup, check the installed record again and record what changed. If you used only the query path in the core exercise, there is no installed utility to remove. Keep your note with the observed release and candidate.
Interview questions with worked answers
What is the difference between refreshing an index and upgrading packages?
Refreshing gets newer information about what is available from the configured sources. Upgrading requests changes to packages installed on the system. On APT, the commands named update and upgrade distinguish those actions. I would identify the local package manager and check its syntax first because command names differ. An index report can change without modifying the installed program version.
The tool is available in a repository but the command appears missing. How would you diagnose it?
I would verify the distribution and release, then compare the candidate with the local installed state. A repository advertisement does not install a program. If the package is installed, I would check which files it owns and where the shell looks for the command. A path from a custom installation may supersede the distribution's path, so I would include both the installed package version and shell command resolution in the diagnosis.
Why does Amazon Linux 2023 show no updates although a newer release exists?
The system may be locked to a particular repository version. A default check for updates can only see available packages in the configured release scope. I would compare the installed release package and the available repository releases, verify the approved target and inspect the planned transaction. No update in the current scope is useful evidence, but it does not certify that the instance has every later security update.
What would you do when a package installation proposes an unexpected removal?
I would decline the change and record the full proposed removal and dependency information. Then I would compare the configured sources, installed version and requirements of the selected package. On a shared system the service owner needs to evaluate the effect of the removed package. For a disposable learning host I can reproduce the same plan under its own release and inspect it before making a change.
Why does a trusted package source still deserve review?
Trust checks help show that content matches what a configured publisher supplied. They do not decide whether the source is appropriate for our release or whether its packages are approved for this machine. I would verify the publisher, signing setup and compatibility, then review the resulting transaction. A valid download may still be the wrong package for the job.
Check your understanding
1. The package manager reports a candidate, with no installed version. What does this tell you?
A. A configured source has information about an eligible package.
B. The command must already be available in this shell.
C. The service using the package has started.
Answer and reasoning
A. A candidate describes what the manager can consider. Look at the actual installed state and the shell path before claiming a program is available to run.
2. Which action updates APT's view of packages without installing a new version of your application?
A. Remove the package.
B. Refresh the package index.
C. Purge its configuration.
Answer and reasoning
B. That action updates repository information in the local index. A separate install or upgrade transaction changes the installed software.
3. An AL2023 update check sees no updates under its configured version. Which next evidence addresses a later release?
A. Check newer AL2023 repository releases through the official workflow.
B. Change to an Ubuntu repository.
C. Delete the local package database.
Answer and reasoning
A. The repository version defines the scope of the check. AWS documents a release notification command for many AL2023 instances and publishes release notes for supported versions.
4. A command runs from a local path but the distribution reports its standard package absent. Is that possible?
A. No, a runnable command always has a record in that database.
B. Yes, the command could come from another installation method.
C. No, the shell can only run from one standard program directory.
Answer and reasoning
B. Inspect the exact command path and query ownership before adding a second copy. The shell does not rely on a package query to resolve an executable.
5. DNF returns 100 from an update check while listing available packages. What should your report say?
A. The package transaction already installed the updates.
B. The repository's authentication definitely failed.
C. Updates are available in the check's configured scope.
Answer and reasoning
C. Interpret the status under the documented check command. This result reports available work. Installation would be a separate transaction.
Revision cards
Identify the OS first
Read the distribution and release record. Check the architecture and available manager. Package names and candidates depend on their source and environment.
Three views of a package
The catalogue describes available candidates. A cached download is a file. The installed database records software the system installed. Check the shell path separately.
A transaction has a scope
Read the planned packages to install, upgrade or remove before you agree. The dependency solver considers the released packages and the system's existing requirements.
Check the configured publisher
Repository verification connects downloads with a configured source. Identify that publisher and its supported distribution. Investigate verification failures before authorizing changes.
AL2023 uses versioned repositories
A query under the installed release may see a smaller set of candidates. Check for newer release versions using the documented workflow.
Verify package state and behavior
Compare the installed record and resolved path before and after. Run one appropriate behavior check. Preserve the starting state when a package predated your exercise.
Official references
- Amazon Linux 2023 package management tool
- Amazon Linux 2023 versioned repositories
- Amazon Linux 2023 update and release checks
- DNF command options, queries and transaction reference
- DNF repository and signature configuration
- Ubuntu Server package management guide
- Debian APT command and simulation reference
- Debian APT archive authentication
- Debian installed package queries and status fields