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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • 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. Repairing filesystem issues at Boot in CentOS/RHEL 7 and 8
  2. RHEL 7 – RHCSA Notes – System documentation including man, info, and files in /usr/share/doc
  3. ldconfig: command not found
  4. fwupdmgr: command not found
  5. Replacing a Failed Mirror Disk in a Software RAID Array (mdadm)
  6. How to Remove a Dead Mulitpath Device without Reboot in CentOS/RHEL
  7. How to test a PHP script
  8. How to use perf tool for tracing similar to dtrace
  9. just Command Examples in Linux
  10. lynis Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • protonvpn-cli Command Examples in Linux
  • protonvpn-cli connect Command Examples
  • procs Command Examples in Linux
  • prlimit: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright