Linux emerge Command with Practical Examples

LinuxLinuxBeginner
Practice Now

Introduction

In this lab, we will explore the emerge command, the package management tool used in Gentoo Linux and its derivatives. We will learn how to install packages, update the system, and upgrade packages using the emerge command. First, we will introduce the emerge command and check its version. Then, we will explore the available options and commands for the emerge tool. Finally, we will update the package database, check for package updates, and upgrade the system using the emerge command.

Linux Commands Cheat Sheet


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/BasicSystemCommandsGroup(["`Basic System Commands`"]) linux(("`Linux`")) -.-> linux/TextProcessingGroup(["`Text Processing`"]) linux(("`Linux`")) -.-> linux/UserandGroupManagementGroup(["`User and Group Management`"]) linux(("`Linux`")) -.-> linux/SystemInformationandMonitoringGroup(["`System Information and Monitoring`"]) linux/BasicSystemCommandsGroup -.-> linux/echo("`Text Display`") linux/TextProcessingGroup -.-> linux/grep("`Pattern Searching`") linux/UserandGroupManagementGroup -.-> linux/sudo("`Privilege Granting`") linux/SystemInformationandMonitoringGroup -.-> linux/ps("`Process Displaying`") subgraph Lab Skills linux/echo -.-> lab-422662{{"`Linux emerge Command with Practical Examples`"}} linux/grep -.-> lab-422662{{"`Linux emerge Command with Practical Examples`"}} linux/sudo -.-> lab-422662{{"`Linux emerge Command with Practical Examples`"}} linux/ps -.-> lab-422662{{"`Linux emerge Command with Practical Examples`"}} end

Introduction to the emerge Command

In this step, we will explore the emerge command, which is the package management tool used in Gentoo Linux and its derivatives. The emerge command is a powerful tool that allows you to install, update, and manage packages on your system.

First, let's check the version of the emerge command installed on our system:

sudo emerge --version

Example output:

Portage 3.0.28 (python 3.10.6-final-0, default/linux/amd64/17.1, gcc-12.2.0, glibc-2.36-r3, 5.15.0-57-generic x86_64)

As you can see, the emerge command is part of the Portage package management system used in Gentoo Linux. Portage is a sophisticated package management system that provides advanced features like dependency resolution, package masking, and more.

Now, let's explore some basic usage of the emerge command:

sudo emerge --help

This will display the available options and commands for the emerge tool.

Updating and Upgrading the System with emerge

In this step, we will learn how to use the emerge command to update and upgrade the packages on our system.

First, let's update the package database to ensure we have the latest information about available packages:

sudo emerge --sync

This command will synchronize the local package database with the remote Portage tree, ensuring we have the latest package versions available.

Next, we can check for any package updates available on the system:

sudo emerge --update --deep --newuse @world

The --update option checks for package updates, --deep ensures dependencies are also updated, and --newuse will update packages if new USE flags are available.

The @world target represents all installed packages on the system.

Example output:

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  R     ] sys-libs/glibc-2.36-r3  USE="acl caps crypt headers-only multilib nscd rpc selinux -audit -bound-nsl -compile-locales -doc -gd -headers -internal-dns -multiarch -nscd-compat -profile -suid -systemtap" ABI_X86="(64)"
[ebuild  R     ] sys-apps/util-linux-2.38.1  USE="cramfs fdformat ncurses nls pam readline static-libs unicode -build -doc -kill -logger -magic -python -setpriv -slang -su -systemd"
[ebuild  R     ] sys-devel/gcc-12.2.0  USE="cxx fortran graphite lto (multilib) nls nptl openmp (pie) (ssp) (vanilla) -ada -awt -debug -doc -go -jit -libssp -mpx -offense -pgo -regression-test -sanitize -selinux -systemtap"
[ebuild  R     ] sys-libs/zlib-1.2.13  USE="minizip static-libs"

Total: 4 packages (4 reinstalls), Size of downloads: 47,424 KiB

Would you like to merge these packages? [Yes/No]

After reviewing the list of packages to be updated, we can confirm the update process by entering "Yes".

The emerge command will then download, compile, and install the updated packages on our system.

Summary

In this lab, we explored the emerge command, which is the package management tool used in Gentoo Linux and its derivatives. We learned how to check the version of the emerge command, and how to use it to install, update, and upgrade packages on the system. We also learned how to update the package database and check for available package updates, as well as how to perform a full system upgrade using the emerge command.

Linux Commands Cheat Sheet

Other Linux Tutorials you may like