Use archives within Linux CLI: Difference between revisions

From WikiMLT
Spas (talk | contribs)
m Стадий: 4 [Фаза:Авторизиране, Статус:Разработен]; Категория:Linux Server
Spas (talk | contribs)
m Стадий: 5 [Фаза:Утвърждаване, Статус:Авторизиран]; Категория:Linux Server
Line 63: Line 63:
{{devStage  
{{devStage  
  | Прндл  = Linux Server
  | Прндл  = Linux Server
  | Стадий = 4
  | Стадий = 5
  | Фаза  = Авторизиране
  | Фаза  = Утвърждаване
  | Статус = Разработен
  | Статус = Авторизиран
  | ИдтПт  = Spas
  | ИдтПт  = Spas
  | РзбПт  = Spas
  | РзбПт  = Spas
  | АвтПт  = {{REVISIONUSER}}
  | АвтПт  = Spas
  | УтвПт  = Spas
  | УтвПт  = {{REVISIONUSER}}
  | ИдтДт  = 7.07.2022
  | ИдтДт  = 7.07.2022
  | РзбДт  = 15.08.2022
  | РзбДт  = 15.08.2022
  | АвтДт  = {{Today}}
  | АвтДт  = 15.08.2022
  | УтвДт  = 7.07.2022
  | УтвДт  = {{Today}}
  | ИдтРв  = [[Special:Permalink/27794|27794]]
  | ИдтРв  = [[Special:Permalink/27794|27794]]
  | РзбРв  = [[Special:Permalink/30175|30175]]
  | РзбРв  = [[Special:Permalink/30175|30175]]
  | АвтРв  = {{REVISIONID}}
  | АвтРв  = [[Special:Permalink/30177|30177]]
  | РзАРв  = [[Special:Permalink/27806|27806]]
  | РзАРв  = [[Special:Permalink/27806|27806]]
| УтвРв  = {{REVISIONID}}
  | РзУРв  = [[Special:Permalink/27809|27809]]
  | РзУРв  = [[Special:Permalink/27809|27809]]
}}
}}
</div>
</div>
</noinclude>
</noinclude>

Revision as of 04:52, 15 August 2022

Tar

  • Note .tgz === .tar.gz

Cre­ate a gzip-com­pressed archive

tar czvf archived-file.tar.gz /my/directory/or/file_1 /my/directory/or/file_2
  • -c, --create – cre­ate a new archive,
  • -z, --gzip – fil­ter the archive through gzip,
  • -v, --verbose – ver­bose­ly list files processed,
  • -f – use archive file or de­vice ARCHIVE – it must be the last op­tion, oth­er­wise you can use --file=ARCHIVE.

Ex­tract a gzip-com­pressed archive

tar xzvf my-file.tar.gz
  • -x, --extract, --get – ex­tract files from an archive,
  • The rest op­tions are the same as the above,
  • the com­pres­sion type (-z in this case) could be omit­ted, be­cause tar will de­tect it au­to­mat­i­cal­ly.

Ex­tract bzip2-com­pressed archives

tar -xjf nextcloud-[version].tar.bz2

7zip

7zip is not in­stalled by de­fault with most Lin­ux dis­tri­b­u­tions, so on De­bian based dis­tri­b­u­tion you can in­stall it by the fol­low­ing com­mand.

sudo apt update && sudo apt install p7zip-full

IMO, 7zip is the best or at least the most eas­i­est way to cre­ate pass­word pro­tect­ed com­pressed archive with­in the com­mand line.

Cre­ate a 7z-com­pressed archive

7z a archive.7z /directory/or/file # create 7z compressed archive
7z a archive.7z * -p               # create password protected archive, enter the password in prompt
7z a archive.7z * -p'SECRET @#!'   # create password protected archive, append the password to the command
  • a – cre­ate archive,
  • -p – pass­word pro­tect­ed [fol­lowed by the pass phrase].

Ex­tract a 7z-com­pressed archive

7z x archive.7z     # extract an archive in the current directory
7z x archive.7z -p  # extract a password protected archive in the current directory
7z x archive.7z -p'SECRET @#!'              # append the password to the command
7z x archive.7z -p'SECRET' -o'/otput/dir/'  # set an output directory
  • x – ex­tract,
  • -o – out­put di­rec­to­ry.

Un­zip

unzip nextcloud-[version].zip

Ref­er­ence