opkg

packageEmbedded Linux
The opkg command is one of the most frequently used commands in Linux/Unix-like operating systems. opkg Lightweight package management system for embedded Linux devices

Quick Reference

Command Name:

opkg

Category:

package

Platform:

Embedded Linux

Basic Usage:

opkg [options] [arguments]

Common Use Cases

    Syntax

    opkg [options] sub-command [arguments]

    Options

    Option Description
    -A Allow package downgrade
    -f, --force-depends Install/remove despite failed dependencies
    --force-maintainer Overwrite local configuration files with those from the packages
    --force-reinstall Reinstall packages that are already installed
    --force-overwrite Overwrite files from other packages
    --force-downgrade Allow package downgrade
    --force-space Install even with insufficient disk space
    --force-removal-of-dependent-packages Remove packages that depend on the package being removed
    --autoremove Remove packages that were installed automatically to satisfy dependencies
    --offline-root PATH Use PATH as the root directory for offline installation
    -t, --tmp-dir PATH Use PATH for temporary files
    -d, --dest NAME Use NAME as the destination name
    -v, --verbose Enable verbose output
    -V, --verbosity=LEVEL Set verbosity level to LEVEL
    -h, --help Display help information

    Common Subcommands:

    Subcommand Description
    update Update list of available packages
    upgrade Upgrade installed packages
    install <pkg> Install package(s)
    remove <pkg> Remove package(s)
    configure Configure unpacked packages
    list List available packages
    list-installed List installed packages
    list-upgradable List installed packages that can be upgraded
    info <pkg> Display information about package(s)
    status <pkg> Display status of package(s)
    download <pkg> Download package(s)
    compare-versions <v1> <op> <v2> Compare version strings (operators: <=, >=, =, <<, >>)
    print-architecture Display target architecture
    search <pattern> Search for packages matching a pattern
    files <pkg> List files owned by package(s)
    find <file> Find package owning file

    Examples

    How to Use These Examples

    The examples below show common ways to use the opkg command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.

    # Basic Examples Basic
    opkg update
    Update the list of available packages.
    opkg install package_name
    Install a package.
    # Advanced Examples Advanced
    opkg remove package_name Remove an installed package. opkg upgrade Upgrade all installed packages to their latest versions. opkg list List all available packages. opkg list-installed List all installed packages. opkg info package_name Display detailed information about a package. opkg files package_name List all files owned by a package. opkg search file_name Search for packages containing a specific file. opkg download package_name Download a package without installing it.

    Try It Yourself

    Practice makes perfect! The best way to learn is by trying these examples on your own system with real files.

    Understanding Syntax

    Pay attention to the syntax coloring: commands, options, and file paths are highlighted differently.

    Notes

    OPKG (Open PacKaGe Management) is a lightweight package management system designed specifically for embedded Linux devices with limited storage and memory resources. It is derived from the IPK packaging system used in Familiar Linux and is widely used in embedded platforms such as OpenWrt, LEDE, OpenEmbedded, and various IoT devices. As a successor to the ipkg (Itsy Package Management System), opkg maintains backward compatibility while offering enhanced functionality and performance. It's particularly well-suited for resource-constrained environments where more robust package managers like APT or YUM might be too heavy. Key features of the opkg command: 1. Lightweight Design: opkg is optimized for embedded systems with limited resources, requiring minimal RAM and storage overhead compared to full-featured package managers. 2. Package Dependencies: Despite its small footprint, opkg properly handles package dependencies, ensuring that all required components are installed for a package to function correctly. 3. Configuration Management: The system respects local configuration files and provides options for handling conflicts between package-provided and locally-modified configurations. 4. Package Repositories: opkg supports multiple package repositories, allowing devices to access different sources for packages based on their needs. 5. Package Verification: Basic integrity verification is supported to ensure packages haven't been tampered with during transfer. 6. Offline Installation: opkg supports installation to alternate root directories, which is useful for preparing images or updating devices that aren't directly connected to the internet. Common use cases for opkg include: - Managing software on embedded Linux devices like routers, IoT gateways, and network appliances - Installing, updating, and removing packages on resource-constrained systems - Building custom firmware images with specific package sets - Deploying software updates to field-deployed embedded devices - Cross-platform development for embedded Linux targets - Managing software on customized Linux distributions for specialized hardware The configuration for opkg is typically found in /etc/opkg.conf and in files under /etc/opkg/, which specify package repositories and other operational parameters. Package files for opkg typically use the .ipk extension, which are essentially specialized ZIP archives containing the package data and metadata. While opkg provides functionality similar to more comprehensive package management systems, it does have limitations. It lacks some advanced features found in systems like APT, such as complex dependency resolution algorithms and extensive package verification. However, these trade-offs are intentional to maintain its lightweight nature, making it ideal for embedded systems where resource efficiency is critical. For developers and users of embedded Linux systems, understanding opkg is essential for effective software management and deployment across a wide range of devices and platforms.

    Related Commands

    These commands are frequently used alongside opkg or serve similar purposes:

    Use Cases

    Learn By Doing

    The best way to learn Linux commands is by practicing. Try out these examples in your terminal to build muscle memory and understand how the opkg command works in different scenarios.

    $ opkg
    View All Commands