Extracting and Compressing Files on Linux

The following are commands that must be given from a console session. If you are working on a remote server you will need SSH access to use these commands. On some systems you will need to precede the commands with sudo to gain administrator access. You will need to provide your password when prompted after giving sudo [commands…] from the console.

File Compression

tar cvzf test.tar.gz /www/test/

Makes a tar.gz compressed archive named test.tar.gz from the test directory, including all sub directories under test.

  • c: create a new archive
  • v: verbose output
  • z: use gzip compression
  • f: save archive as file

Extraction

tar.gz

tar xvzf test.tar.gz 

Extracts the files in the test.tar.gz archive

  • x: extraction
  • z: implies either compression or expansion depending on use
tar -xvzf file.tar.gz -C directory

Extracts to the indicated directory.

tar.bz2

tar -xvjf file.tar.bz2 -C directory

Extracts a tar.bz2 compressed file.

  • j: indicates bz2

zip

unzip file.zip

Extracts a windows zip archive.


Up one level
 
kb/linux/archives.txt · Last modified: 2009-07-15 05:22 pm by admin
Recent changes RSS feed Creative Commons License Driven by DokuWiki
Basically Brilliant! Home
Basically Brilliant! Blog