notes/tar.md

65 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

### TAR
**Создать архив**
```
tar -cvf archivename.tar /files-you-want-toarchive
```
-c, --create create a new archive
-v, --verbose verbosely list files processed
-f, --file=ARCHIVE use archive file or device ARCHIVE
**Создать архив со сжатием**
```
tar -czvf archivename.tar.gz /files-you-want-toarchive
```
-j, --bzip2 filter the archive through bzip2
-J, --xz filter the archive through xz
-z, --gzip, --gunzip, --ungzip filter the archive through gzip
**Добавить файл в существующий архив**
```
tar -rvf /root/homes.tar /etc/hosts
```
-r, --append append files to the end of an archive
**Обновить файлы в существующем архиве**
```
tar -uvf /root/homes.tar /home
```
-u, --update only append files newer than copy in archive
**Просмотр содержимого архива**
```
tar -tvf /root/homes.tar
```
-t, --list list the contents of an archive
**Извлечь файлы из архива в текущий каталог**
```
tar -xvf /archivename
```
-x, --extract, --get extract files from an archive
**Извлечь файлы из сжатого архива**
```
tar -xzvf archivename.tar.gz
```
**Извлечь файлы из архива в другой каталог**
```
tar -xvf /archivename -C /tmp
```
-C, --directory=DIR change to directory DIR
**Извлечь определённый файл из архива**
```
tar -xvf /root/etc.tar etc/hosts
```