SIMULATION -
Create a backup -
Create a backup file named /root/backup.tar.bz2, contains the content of /usr/local, tar must use bzip2 to compress.
SIMULATION -
Create a backup -
Create a backup file named /root/backup.tar.bz2, contains the content of /usr/local, tar must use bzip2 to compress.
To create a backup file named /root/backup.tar.bz2 containing the contents of /usr/local and compressed using bzip2, you should use the following steps: You don't need to change directories. First, use the tar command with the -jcvf options. -j tells it to use bzip2, -c is for create, -v is for verbose which lists the files being processed, and -f specifies the archive file name. The command should be: tar -jcvf /root/backup.tar.bz2 /usr/local. To check the content, you can optionally use tar -jxvf /root/backup.tar.bz2 -C /test after creating a test directory with mkdir /test.
# tar -cjvf /root/backup.tar.bz2 /usr/local
This is the right answer
Simple to understand and execute, [root@station ~]# yum install bzip2 [root@station ~]# tar -cvf /root/backup.tar /usr/local/ [root@station ~]# du -sh /root/backup.tar 20K /root/backup.tar [root@station ~]# bzip2 /root/backup.tar [root@station ~]# du -sh /root/backup.tar.bz2 4.0K /root/backup.tar.bz2 [root@station ~]#
I don't think this is right answer as the question explicitly asks "tar must use bzip2 to compress". Apart from that the answer provided is perfectly valid.
file /root/backup.tar.bz2 ##to check file information, it should show "bzip2 compressed data..."
tar -cjf /root/backup.tar.bz2 /usr/local
can you explain more please
tar -cvf /root/backup.tar /usr/local && bzip2 /root/backup.tar
# tar -cjvf /root/backup.tar /usr/local # bzip2 backup.tar
tar -jcvf /root/backup.tar.bz2 /usr/local
Answer for RHEL8 # cd /usr/local # tar -jcvf /root/backup.tar.bz2 /usr/local # mkdir /test # tar -jxcf /root/backup.tar.bz2 -C /usr/local If you do it the way the original answer says it will return the "cowardly refusing" error
Last command should be: tar -jxcf /root/backup.tar.bz2 -C /test
#tar -cavf /root/backup.tar.bz2 /usr/local