Learn how rpm -qa lists packages recorded in the RPM database, then see how grep narrows that list to nano. This simple shell pipeline makes package checks quick and clear, while also showing how Linux tools can work together for everyday system administration.

Multiple Choice

Which command shows that the nano package is installed by querying installed packages and filtering for nano?

Verifying installation by querying the RPM database and filtering for the package name. The command rpm -qa lists all installed packages, one per line. Piping that output to grep nano searches for any line that contains nano, so you can quickly confirm whether the nano package is present. If nano is installed, you’ll see its package entry; if not, there’s no match. This approach directly answers “is nano installed?” by scanning the installed package list, whereas the other options either show all packages without filtering, display package files, or show metadata without performing a simple search in the installed-list.

Checking Installed Packages on a Linux System

When a Linux system behaves unexpectedly, one useful first step is to check which software is installed. On Red Hat-based systems, the RPM package manager keeps a database of installed packages, and the rpm command can query it. For a quick search, you can list installed packages and send that list through grep:


rpm -qa | grep nano

If a package with “nano” in its name is installed, its package entry should appear in the output. If nothing appears, there’s no matching entry in the list. It’s a small command, but it shows a useful Linux habit: combine focused tools to answer a practical question.

A package list, then a filter

The first part, rpm -qa, asks RPM to query all installed packages. The output is usually one package per line, with details such as its name, version, release, and system architecture. A line might look like this:


nano-5.6.1-5.el9.x86_64

The pipe symbol, |, passes the output of the command on its left to the command on its right. Here, that means the full package list flows into grep nano. The grep program searches each line for the text nano and prints lines that match.

Think of it like looking through a long paper directory with a highlighter. rpm -qa produces the directory; grep marks the entries you asked it to find. Each command has one clear job, and the pipe connects them.

What the result tells you—and what it doesn’t

A matching line is evidence that an installed package name contains the text nano. No output means grep found no matching line in the package list. For a quick check, that’s often all you need.

Still, a blank result deserves a little care. It doesn’t explain why there was no match. The package may not be installed, its name may differ from the one you expected, or the search term may not match how the package is named. In a script, an error could also affect the result, so it can be useful to look at the command’s exit status or inspect any error message.

The exact package entry can vary by distribution release and architecture. A package name may include version and release details, while some systems use different naming conventions. The key point is that grep nano looks for a string in each line; it doesn’t understand package relationships or guess what you meant.

For a broader search, use a shorter fragment:


rpm -qa | grep -i nano

The -i flag tells grep to ignore letter case. That can help when you’re unsure whether a name contains uppercase or lowercase letters, though Linux package names are commonly written in lowercase.

A more direct RPM query

The pipeline is handy when you want to scan a package list, but RPM also has a direct query for a named package:


rpm -q nano

This asks the RPM database specifically about nano, rather than listing every package and filtering the output. If RPM finds the package, it prints its installed name and version. If it doesn’t, it reports that the package isn’t installed.

So why use the longer pipeline at all? Because it’s a flexible pattern. You can swap nano for another search term, look for several related packages, or send the package list into another text-processing tool. The direct query is often more precise when you know the package’s exact name; the pipeline is useful when you’re scanning or exploring.

That distinction comes up often in system administration. A broad search helps you get your bearings. A targeted query confirms a specific detail.

Similar commands, different jobs

RPM has several query options, and they can look alike at first. Their results differ:

  • rpm -qa prints the names of all installed packages.

  • rpm -q nano checks whether a package named nano is installed.

  • rpm -ql nano lists files associated with the installed package.

  • rpm -qi nano displays information about the package, such as its version and description.

The final letter matters. In -qa, the a means all. In -ql, the l requests a file list. In -qi, the i requests package information. Small flags, big difference.

These commands answer separate questions. “Is this package installed?” is not the same as “Which files did it install?” or “What does its metadata say?” Knowing what you want to learn makes the command easier to choose—and makes the output easier to interpret.

When package tools meet

Many Red Hat-based systems also use DNF to manage software. DNF works at a higher level: it can install packages, remove them, and resolve dependencies by consulting software repositories. RPM focuses on package files and the local RPM database. They work together, but they serve different roles.

To view installed packages with DNF, you can use:


dnf list installed

For a quick search, pipe the output through grep:


dnf list installed | grep -i nano

DNF’s output may include repository or status details, so it can look different from RPM’s list. When all you need is a direct check in the local RPM database, rpm -q nano is concise. When you want to browse a wider set of installed software or work with repository information, DNF may be more useful.

One detail is easy to miss: package names and the commands they provide aren’t always identical. A program called from the terminal may come from a package with a different name. If a search for the command name comes up empty, check the software’s documentation or search for a related package name rather than assuming something is broken.

A reliable little workflow

For a quick check, start with a direct query if you know the package name:


rpm -q nano

If you’re not sure what the package is called, search the installed list:


rpm -qa | grep -i nano

Then, if you need more detail, inspect the package information or list its files:


rpm -qi nano

rpm -ql nano

This sequence moves from a broad clue to a precise answer, then to supporting details. It’s a tidy way to investigate without flooding the screen with information you don’t need.

Package queries may feel like small housekeeping commands, but they help build a clear picture of a system. A missing editor, a service that won’t start, or an unexpected file can all lead back to the same question: what software is actually installed? With RPM, a short command—or a pipe connecting two short commands—can make that question much easier to answer.