• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

lxc Command Examples in Linux

by admin

lxc is a command-line tool in Linux used to manage Linux containers. The tool communicates with a container manager service, such as lxd, using the lxd REST API. Containers are isolated environments that allow you to run applications and services in a contained, isolated environment within a host operating system.

The lxc command provides a simple and convenient way to manage containers, including:

  • Launching new containers
  • Stopping and starting existing containers
  • Displaying information about containers
  • Copying containers
  • Moving containers between hosts And more.

The lxc command can be used to manage containers on a local host or on remote servers. The name of a remote server can be prefixed to container names or patterns to specify the target server for operations. This allows you to manage containers on multiple servers from a single command-line interface.

The lxc command is a powerful tool for managing containers, making it easy to launch and manage isolated environments for applications and services. The integration with the lxd REST API allows for a flexible, scalable, and secure way to manage containers in Linux.

lxc Command Examples

1. List local containers matching a string. Omit the string to list all local containers:

# lxc list match_string

2. List images matching a string. Omit the string to list all images:

# lxc image list [remote:]match_string

3. Create a new container from an image:

# lxc init [remote:]image container

4. Start a container:

# lxc start [remote:]container

5. Stop a container:

# lxc stop [remote:]container

6. Show detailed info about a container:

# lxc info [remote:]container

7. Take a snapshot of a container:

# lxc snapshot [remote:]container snapshot

8. Execute a specific command inside a container:

# lxc exec [remote:]container command

lxc profile Command Examples

1. List all available profiles:

# lxc profile list

2. Show the configuration of a specific profile:

# lxc profile show profile_name

3. Edit a specific profile in the default editor:

# lxc profile edit profile_name

4. Edit a specific profile importing the configuration values from a file:

# lxc profile edit profile_name < config.yaml

5. Launch a new container with specific profiles:

# lxc launch container_image container_name --profile profile1 --profile profile2

6. Change the profiles of a running container:

# lxc profile assign container_name profile1,profile2

lxc network Command Examples

1. List all available networks:

# lxc network list

2. Show the configuration of a specific network:

# lxc network show network_name

3. Add a running instance to a specific network:

# lxc network attach network_name container_name

4. Create a new managed network:

# lxc network create network_name

5. Set a bridge interface of a specific network:

# lxc network set network_name bridge.external_interfaces eth0

6. Disable NAT for a specific network:

# lxc network set network_name ipv4.nat false

Filed Under: Linux

Some more articles you might also be interested in …

  1. How to Find and Delete Empty Directories and Files in Linux
  2. pvremove Command Examples in Linux
  3. terminator Command Examples in Linux
  4. iw: command not found
  5. join Command Examples
  6. Troubleshooting common NFS issues in Linux
  7. aplay Command Examples in Linux
  8. Mac Terminal vi[m] Editor Commands
  9. dcode: Recursively detect and decode strings, supporting hex, decimal, binary, base64, URL, FromChar encodings, Caesar ciphers, and MD5, SHA1, and SHA2 hashes
  10. playerctl: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright