Red Hat System Administration II
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 toserveraas thestudentuser and switch to therootuser.[student@workstation ~]$
ssh student@servera...output omitted... [student@servera ~]$sudo -i[sudo] password for student:student[root@servera ~]#Create an archive of the
/etcdirectory withgzipcompression. Save the archive file as/tmp/etc.tar.gz.[root@servera ~]#
tar -czf /tmp/etc.tar.gz /etctar: Removing leading `/' from member namesVerify that the
etc.tar.gzarchive contains the files from the/etcdirectory.[root@servera ~]#
tar -tzf /tmp/etc.tar.gzetc/ etc/mtab etc/fstab etc/crypttab etc/resolv.conf ...output omitted...Create the
/backuptestdirectory. Verify that theetc.tar.gzbackup file is a valid archive by decompressing the file to the/backuptestdirectory.Create the
/backuptestdirectory and change to that directory.[root@servera ~]#
mkdir /backuptest[root@servera ~]#cd /backuptest[root@servera backuptest]#Extract the
/tmp/etc.tar.gzarchive to the/backuptestdirectory.[root@servera backuptest]#
tar -xzf /tmp/etc.tar.gzList the contents of the
/backuptestdirectory. Verify that the directory contains the/etcdirectory 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
workstationsystem as thestudentuser.[root@servera backuptest]#
exitlogout [student@servera ~]$exitlogout Connection to servera closed. [student@workstation]$