Knowledge base
  • Goal of knowledge base
  • Linux & core
    • Linux
      • Record SSH session for reporting
      • Compress / Decompress files
      • Colorize logs
      • Cron output & logging
      • Signal
      • Break out and escape SSH session
      • Mount volume permanently
      • Show processes most consuming CPU & MEM
      • Improve and optimize battery life on Linux
      • File ownership & groups in linux
      • Automatic security update/patch on Ubuntu
      • Clean buffers and cached on linux
      • Bash completion on Linux/Mac
    • Core services
      • Nginx reload
      • OpenVPN Split tunneling
      • Nmap commands
    • Hardware
      • CPU Architecture fundamental
  • Database
    • MySQL
      • InnoDB - innodb_file_per_table parameter
      • MySQL - enable slow query log
      • MySQL - export large tables
    • MongoDB
  • Container
    • Docker
      • ADD or COPY in Dockerfile
        • Clean data of docker completely
    • Podman
  • Automation
    • Ansible
      • Output format
  • Build & Deployment
    • Jenkins
      • Jenkins - force exit pipeline when failure
  • Language & Toolset
    • PHP
      • Composer
      • php-redis & php-igbinary
  • Mindset
    • Technical based
      • Writing well
      • Reinvent The Wheel
      • Approach a new system
      • Backup philosophy
      • Mindset for building HA and scalable system
      • GitLab database incident
    • Non-technical based
      • How to read news efficiency?
      • How long should you nap?
      • Assume good faith
  • Reference & learning source
    • Books
      • Sysadmin/SRE
      • Mindsets
      • Software fundamentals
    • English
Powered by GitBook
On this page
  • 0. Requirement packages
  • 1. Compress
  • 2. Decompress
  1. Linux & core
  2. Linux

Compress / Decompress files

0. Requirement packages

apt install tar zip unzip gzip

1. Compress

  • Compress single file into .tar.gz

tar -zcvf telegraf-legacy.log.tar.gz telegraf.log --totals --verbose
  • Compress a directory into .tar.gz

tar -zczf monit-5.26.0.tar.gz monit-5.26.0/ --totals --verbose

After that if you want remove original file then use with option --remove-files

  • Compress single file into .gz

# From tocdo.log --> tocdo.gz (dropped original file)

gzip tocdo.log 
  • Compress single file into .zip

# From tocdo.log --> tocdo.zip (dropped original file)

zip x tocdo.log

2. Decompress

tar -xzf foo.tar.gz --totals --verbose
unzip -a x.zip
PreviousRecord SSH session for reportingNextColorize logs

Last updated 5 years ago