less than 1 minute read

Note: This is an RHCSA 7 exam objective.

To compress a file, type:

# gzip file
# bzip2 file

To uncompress a file, type:

# gunzip file.gz
# bunzip2 file.bz2

To archive and compress a directory (with the SELinux contexts), type:

# tar --selinux -czvf directory.tgz directory

Note: Try to avoid using full path when specifying the directory path, use relative path, it will be easier when restoring.

Alternatively, you can group both operations (tar+compression) in one command (respectively for gzip and bzip2 content):

# tar cvzf directory.tgz directory
# tar cvjf directory.bz2 directory

To unpack and uncompress an archive file (respectively for gunzip and bunzip2 content) (with the SELinux contexts), type:

# tar --selinux xzvf directory.tgz
# tar --selinux xjvf directory.bz2

To list the archive content (respectively for gunzip and bunzip2 content), type:

# tar tzvf directory.tgz
# tar tjvf directory.bz2

To archive a directory with the star command (with the SELinux contexts), type:

# yum install -y star
# star -xattr -H=exustar -c -f=directory.star directory

To unpack a archive file, type:

# star -x -f=directory.star

Additional Resources

The linoxide website provides a tutorial about Relax and Recover, the new Open Source disaster recovery solution.

Leave a comment