In this exercise, you create archive files and extract their contents with the tar command.
Outcomes
Archive a directory tree and extract the archive content to another location.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command ensures that all required resources are available.
[student@workstation ~]$ lab start archive-manage
Instructions
From workstation, log in to servera as the student user and switch to the root user.
[student@workstation ~]$ssh student@servera...output omitted... [student@servera ~]$sudo -i[sudo] password for student:student[root@servera ~]#
Create an archive of the /etc directory with gzip compression.
Save the archive file as /tmp/etc.tar.gz.
[root@servera ~]# tar -czf /tmp/etc.tar.gz /etc
tar: Removing leading `/' from member namesVerify that the etc.tar.gz archive contains the files from the /etc directory.
[root@servera ~]# tar -tzf /tmp/etc.tar.gz
etc/
etc/mtab
etc/fstab
etc/crypttab
etc/resolv.conf
...output omitted...Create the /backuptest directory.
Verify that the etc.tar.gz backup file is a valid archive by decompressing the file to the /backuptest directory.
Create the /backuptest directory and change to that directory.
[root@servera ~]#mkdir /backuptest[root@servera ~]#cd /backuptest[root@servera backuptest]#
Extract the /tmp/etc.tar.gz archive to the /backuptest directory.
[root@servera backuptest]# tar -xzf /tmp/etc.tar.gzList the contents of the /backuptest directory.
Verify that the directory contains the /etc directory backup files.
[root@servera backuptest]#ls -ltotal 12 drwxr-xr-x. 95 root root 8192 Feb 8 10:16 etc [root@servera backuptest]#ls -l etctotal 1228 -rw-r--r--. 1 root root 12 Feb 24 05:25 adjtime -rw-r--r--. 1 root root 1529 Jun 23 2020 aliases drwxr-xr-x. 2 root root 4096 Mar 3 04:48 alternatives ...output omitted...
Return to the workstation system as the student user.
[root@servera backuptest]#exitlogout [student@servera ~]$exitlogout Connection to servera closed. [student@workstation]$
This concludes the section.