Too often I figure out how to do this or that on Linux systems and in my haste to complete whatever task I've been assigned this "How To" knowledge gets lost. So here, I will begin posting little odds and ends in hopes of not needing to re-research past efforts for Linux tips, tricks, hacks, and other good to know things. If you find yourself here and know of smaller, faster, better ways of doing any of this please let me know - only through cooperation can we all get better.

Computer files containing sensitive information should also be 'shredded'. There is a command line utility on Linux systems called 'shred' that overwrites the file multiple times with random output. If you simply erase a file with 'rm', this only tells the operating system that this part of your hard disk is free for use, but the information still exists until that space is overwritten. Information from a file that has been deleted can still be recovered unless it has been 'shred', making it nearly impossible to recover.

The following command will shred a file, "zero" it (to hide shredding) and then remove it.

Wednesday, October 14, 2009

How to create a compressed tar.gz file from a folder or file in Linux?
In order to create a compressed tar.gz archive from a folder/file we need to run the following tar command:

tar czf new-tar-file-name.tar.gz file-or-folder-to-archive

Here is the command explanation:

* tar - the tar command.
* c - create new archive.
* z - compress the archive using gzip.
* f - use archive file.
* new-tar-file-name.tar.gz - the name of the tar.gz to create.
* file-or-folder-to-archive - the name of the folder we want to archive.

How to create a compressed tar.gz file from multiple files and folders in Linux?
In order to create a compressed tar.gz file from multiple files or/and folders we need to run the same tar command we used when we archived a single file/folder and to append the rest of the files/folders' names to it.

tar -czf new-tar-file-name.tar.gz file1 file2 folder1 folder2

How to extract a compressed tar.gz file in Linux?
tar -xzf tar-file-name.tar.gz