> For the complete documentation index, see [llms.txt](https://mysther.gitbook.io/knowledge-base/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://mysther.gitbook.io/knowledge-base/sistemas-operacionais/linux/utilizacao/trabalhando-com-arquivos/arquivos-compactados.md).

# Arquivos Compactados

A compactação de arquivos é sem dúvida algo muito útil para transportarmos arquivos. Esse é um processo que permite unir vários arquivos em um único lugar (um novo arquivo) e ocupando um tamanho em disco ainda menor.

### Compactando

#### zip

Sem senha

```bash
zip <file.zip> <file1> <file2> <file3>
```

Com senha

```bash
zip -er <file.zip> <file>
```

#### tar

```bash
tar -cvf </file.tar> --absolute-names <file.txt>
```

#### 7z

Instalando

```bash
sudo apt update
sudo apt install p7zip-full
```

Com senha

```bash
7z a <output.7z> </path/to/crypt> -p'<pass>' -mhe=on
```

### Descompactando

#### zip

```bash
# Listando arquivos
zipinfo <file.zip>

# Descompactando
unzip <file.zip>
unzip <file.zip> -d <folder_output>
```

#### gz

```bash
tar -xzvf <file.tar.gz>
gunzip <file.gz>
gzip -d <file.gz>
```

#### tgz

```bash
tar -zxvf <file.tgz>
```

#### tar

```bash
tar -xvf <file.tar>
```

#### tbz

```bash
tar -jxvf <file.tbz>
```

#### bz2

```bash
bzip2 -dkv <file.bz2>
bunzip2 <file.bz2>
```

#### cpio

```bash
cpio -idv --no-absolute-filename < <cpio_file>
```

#### xz

```bash
unxz <file.xz>
```

#### 7z

```bash
# Listando arquivos
7za l <file.7z>

# Descompactando
7za x <file.7z>

# Com senha
7z x <output.7z> -p'<pass>'
```

#### jar

```bash
jar xf <file.jar>
```

### Visualizando Conteúdo

#### zipinfo

```bash
﻿﻿zipinfo <file.zip>
```

#### unzip

```bash
unzip -l <file.zip>
```
