Bird
Raised Fist0
Linux CLIscripting~10 mins

yum/dnf (RHEL/CentOS) basics in Linux CLI - Step-by-Step Execution

Choose your learning style10 modes available
Concept Flow - yum/dnf (RHEL/CentOS) basics
Start: User wants to manage packages
↓
Choose command: yum or dnf
↓
Run command with options
↓
System checks repositories
↓
Download package info or packages
↓
Install/Update/Remove packages
↓
Show success or error message
↓
End
This flow shows how yum or dnf commands manage software packages by checking repos, downloading, and installing or removing them.
Execution Sample
Linux CLI
sudo dnf install nano
sudo dnf update
sudo dnf remove nano
These commands install, update, and remove the nano text editor using dnf.
Execution Table
StepCommandActionSystem ResponseOutput Example
1sudo dnf install nanoCheck repos for nano packageFound nano in repoDependencies resolved
2sudo dnf install nanoDownload nano packageDownloading packagesDownloading nano-5.9-1.el8.x86_64.rpm
3sudo dnf install nanoInstall nano packageInstalling packagesInstalled: nano-5.9-1.el8.x86_64
4sudo dnf updateCheck for updatesChecking for updatesNo packages marked for update
5sudo dnf remove nanoCheck installed packagesnano is installedDependencies resolved
6sudo dnf remove nanoRemove nano packageRemoving packagesRemoved: nano-5.9-1.el8.x86_64
7sudo dnf remove nanoConfirm removalnano no longer installedComplete!
8End of commands
💡 Commands finish after installing, updating, or removing packages with success or no changes.
Variable Tracker
VariableStartAfter Step 1After Step 3After Step 4After Step 6Final
nano_package_statusnot installedfound in repoinstalledinstalledremovednot installed
update_statusunknownunknownunknownno updatesno updatesno updates
Key Moments - 3 Insights
Why does the system check repositories before installing?
The system checks repositories to find the package and its dependencies before downloading, as shown in execution_table rows 1 and 2.
What happens if no updates are available when running 'dnf update'?
The system reports 'No packages marked for update' and stops, as seen in execution_table row 4.
Why must we use 'sudo' with yum/dnf commands?
Because installing or removing software needs admin rights, so 'sudo' runs the command with those rights.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the nano package status after step 3?
Afound in repo
Binstalled
Cnot installed
Dremoved
💡 Hint
Check variable_tracker column 'After Step 3' for nano_package_status.
At which step does the system confirm no updates are available?
AStep 2
BStep 6
CStep 4
DStep 1
💡 Hint
Look at execution_table row with 'sudo dnf update' command.
If you remove 'sudo' from the commands, what likely happens?
ACommands fail due to permission denied
BCommands run successfully
CPackages install without confirmation
DSystem updates automatically
💡 Hint
Refer to key_moments about why 'sudo' is needed.
Concept Snapshot
yum/dnf basics:
- Use 'sudo dnf install package' to install software
- Use 'sudo dnf update' to update all packages
- Use 'sudo dnf remove package' to uninstall
- System checks repos, downloads packages, installs/removes
- 'sudo' needed for admin rights
- Output shows progress and success or errors
Full Transcript
This lesson shows how to use yum or dnf commands on RHEL/CentOS to manage software packages. The commands check repositories for packages, download them, and install or remove them. Using 'sudo' is important because these actions need administrator rights. The execution table traces installing the nano editor, updating packages, and removing nano, showing system responses at each step. Variables track the package status and update status through the process. Key moments clarify why repos are checked first, what happens if no updates exist, and why 'sudo' is required. The quiz tests understanding of package status after installation, update checking, and permission needs. The snapshot summarizes the main commands and their behavior for quick reference.

Practice

(1/5)
1. What is the primary purpose of the yum or dnf command on RHEL/CentOS systems?
easy
A. To configure network settings
B. To monitor system hardware performance
C. To edit text files in the terminal
D. To manage software packages by installing, updating, or removing them

Solution

  1. Step 1: Understand the role of yum/dnf

    yum and dnf are package managers used to handle software packages on RHEL/CentOS.
  2. Step 2: Identify the correct function

    They allow users to install, update, and remove software easily.
  3. Final Answer:

    To manage software packages by installing, updating, or removing them -> Option D
  4. Quick Check:

    yum/dnf = software package management [OK]
Hint: yum/dnf commands control software packages [OK]
Common Mistakes:
  • Confusing yum/dnf with system monitoring tools
  • Thinking yum/dnf edits files or network settings
  • Mixing yum/dnf with text editors
2. Which of the following is the correct syntax to install a package named httpd using dnf with automatic yes to prompts?
easy
A. dnf install httpd y
B. dnf -y install httpd
C. dnf -y httpd install
D. dnf httpd install -y

Solution

  1. Step 1: Understand dnf command syntax

    The -y option should come immediately after dnf to apply to the entire command.
  2. Step 2: Check the order of arguments

    Correct syntax is dnf -y install httpd to install with automatic yes.
  3. Final Answer:

    dnf -y install httpd -> Option B
  4. Quick Check:

    dnf -y install package = correct syntax [OK]
Hint: Place -y right after dnf for automatic yes [OK]
Common Mistakes:
  • Putting -y after the package name
  • Mixing argument order causing syntax errors
  • Using incorrect command order
3. What will be the output of the command dnf list installed | grep bash on a system where bash is installed?
medium
A. A list of all packages except bash
B. An error saying 'bash not found'
C. A list line showing the bash package details
D. No output at all

Solution

  1. Step 1: Understand the command components

    dnf list installed lists all installed packages; piping to grep bash filters lines containing 'bash'.
  2. Step 2: Predict output if bash is installed

    Since bash is installed, the output will show the bash package line.
  3. Final Answer:

    A list line showing the bash package details -> Option C
  4. Quick Check:

    dnf list installed | grep bash = bash package line [OK]
Hint: grep filters output lines containing the keyword [OK]
Common Mistakes:
  • Expecting an error if package exists
  • Thinking grep excludes matching lines
  • Assuming no output means package installed
4. You run sudo yum install -y nginx but get an error: Could not find a valid baseurl for repo. What is the most likely cause?
medium
A. Network connection or repository configuration issue
B. The nginx package does not exist
C. You forgot to use sudo
D. The command syntax is incorrect

Solution

  1. Step 1: Analyze the error message

    The error 'Could not find a valid baseurl for repo' means yum/dnf cannot reach the repository URL.
  2. Step 2: Identify common causes

    This usually happens due to network issues or wrong repo configuration, not package absence or syntax errors.
  3. Final Answer:

    Network connection or repository configuration issue -> Option A
  4. Quick Check:

    Repo baseurl error = network or repo config problem [OK]
Hint: Check network and repo config if baseurl error appears [OK]
Common Mistakes:
  • Assuming package missing causes baseurl error
  • Ignoring need for network access
  • Blaming command syntax for repo errors
5. You want to automate updating all packages on a CentOS system without prompts. Which command should you use?
hard
A. sudo dnf update -y
B. sudo yum update
C. sudo dnf install -y
D. sudo yum remove -y

Solution

  1. Step 1: Identify the command to update all packages

    dnf update or yum update updates all installed packages.
  2. Step 2: Add automation to avoid prompts

    Adding -y automatically answers yes to prompts, enabling automation.
  3. Final Answer:

    sudo dnf update -y -> Option A
  4. Quick Check:

    dnf update -y = automated full update [OK]
Hint: Use -y with update to automate package upgrades [OK]
Common Mistakes:
  • Using install instead of update to upgrade packages
  • Forgetting sudo for permission
  • Using remove instead of update
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard