Skip to content

Commit

Permalink
Atualiza a cheatsheet de comandos LXC, melhorando a formatação dos tí…
Browse files Browse the repository at this point in the history
…tulos e organizando as seções para maior clareza.
  • Loading branch information
mdmjunior committed Feb 22, 2025
1 parent c2d7561 commit 4b2f9ee
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions data/blog/lxc-commands-cheatsheet.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ authors: ['default']
Linux Containers (LXC) provide lightweight virtualization, enabling the running of multiple isolated Linux systems on a single host. In this guide, we dive deep
into the most essential LXC commands on Ubuntu 24.04, explaining each one in detail to empower you in efficiently managing your containers.

## 1. `lxc launch`
## **Launch Containers**

The `lxc launch` command creates and starts a new container from an existing image. It combines the creation (`lxc init`) and start (`lxc start`) processes into
one command, making it a convenient way to get a container running quickly.
Expand All @@ -27,7 +27,7 @@ lxc launch <image> <container-name>

This command creates and starts a container named `mycontainer` using the Ubuntu 24.04 image.

## 2. `lxc list`
## **List Containers**

Displays a list of all containers, including their current state, IP addresses, and other relevant information. It's useful for getting an overview
of the containers running on your host.
Expand All @@ -40,7 +40,7 @@ lxc list

This command provides a table of all containers, showing their name, status, IP addresses, and other details.

## 3. `lxc stop`
## **Stop Containers**

Stops a running container. This is useful when you need to shut down a container for maintenance or resource management.

Expand All @@ -52,7 +52,7 @@ lxc stop <container-name>

This command stops the container named `mycontainer`.

## 4. `lxc start`
## **Start Containers**

Starts a stopped container. This is the counterpart to `lxc stop`, allowing you to resume operations on a previously halted container.

Expand All @@ -63,7 +63,7 @@ lxc start <container-name>

This starts the container named `mycontainer`.

## 5. `lxc exec`
## **Container Execution**

Executes a command inside a running container. It is similar to SSH but is more efficient since it does not require an SSH server within the container.

Expand All @@ -77,7 +77,7 @@ lxc exec <container-name> -- <command>

This opens an interactive bash shell inside `mycontainer`.

## 6. `lxc delete`
## **Delete Containers**

Deletes a stopped container permanently. Be cautious as this action is irreversible.

Expand All @@ -88,10 +88,7 @@ lxc delete <container-name>

This deletes the container named `mycontainer`.

---

## 7. `lxc info`

## **Get Container Information**

Displays detailed information about a specific container, including its status, resource usage, network configuration, and more.

Expand All @@ -102,7 +99,7 @@ lxc info <container-name>

This shows comprehensive details about `mycontainer`.

## 8. `lxc snapshot`
## **Container Backup and Snapshot**

Creates a snapshot of the container's current state, enabling you to roll back to this state later if needed.

Expand All @@ -116,8 +113,7 @@ lxc snapshot <container-name> <snapshot-name>

This creates a snapshot named `initial-setup` for `mycontainer`.


## 9. `lxc restore`
## **Restoring**

Restores a container to a previously created snapshot. This is useful for reverting changes or recovering from errors.

Expand All @@ -128,8 +124,7 @@ lxc restore <container-name> <snapshot-name>

This restores `mycontainer` to the state saved in the `initial-setup` snapshot.


## 10. `lxc config`
## **Configuration**

Manages container configurations, including resource limits and device mappings. It allows you to modify the settings of a container dynamically.

Expand All @@ -149,12 +144,6 @@ This sets the CPU limit of `mycontainer` to 2 cores.
These LXC commands are fundamental for efficiently managing containers on Ubuntu 24.04. Mastering them enhances your system administration and
DevOps skills, making it easier to deploy and maintain isolated environments for development and production.


## Related Posts
- [Understanding LXD Containers: An Introduction](#)
- [Installing LXD on Ubuntu 24.04](#)
- [LXD Command Cheatsheet](#)

## References
- [LXC Documentation](https://linuxcontainers.org/lxc/introduction/)
- [Ubuntu LXC Guide](https://help.ubuntu.com/community/LXC)

0 comments on commit 4b2f9ee

Please sign in to comment.