In this exercise, you will create archive files and extract their contents with the tar command.
Outcomes
You should be able to archive a directory tree and extract the archive content to another location.
Log in as the student user on workstation using student as the password.
From workstation, run the lab archive-manage start command.
The command runs a start script that determines if the host, servera, is reachable on the network.
The script also ensures that the file and directory to be created in the exercise does not exist on servera.
[student@workstation ~]$lab archive-manage start
Use the ssh command to log in to servera as the student user.
[student@workstation ~]$ssh student@servera...output omitted...[student@servera ~]$
Switch to the root user as only the root user can access all of the content of the /etc directory.
[student@servera ~]$su -Password:redhat[root@servera ~]#
Use the tar command with the -czf options to create an archive of the /etc directory using gzip compression.
Save the archive file as /tmp/etc.tar.gz.
[root@servera ~]#tar -czf /tmp/etc.tar.gz /etctar: Removing leading `/' from member names[root@servera ~]#
Use the tar command with the -tzf options to verify that the etc.tar.gz archive contains the files from the /etc directory.
[root@servera ~]#tar -tzf /tmp/etc.tar.gzetc/ etc/mtab etc/fstab etc/crypttab etc/resolv.conf ...output omitted...
On servera, create a directory named /backuptest.
Verify that the etc.tar.gz backup file is a valid archive by decompressing the file to the /backuptest directory.
Create the /backuptest directory.
[root@servera ~]#mkdir /backuptest
Change to the /backuptest directory.
[root@servera ~]#cd /backuptest[root@servera backuptest]#
List the contents of the etc.tar.gz archive before extracting.
[root@servera backuptest]#tar -tzf /tmp/etc.tar.gzetc/ etc/mtab etc/fstab etc/crypttab etc/resolv.conf ...output omitted...
Extract the /tmp/etc.tar.gz archive to the /backuptest directory.
[root@servera backuptest]#tar -xzf /tmp/etc.tar.gz[root@servera backuptest]#
List the content of the /backuptest directory.
Verify that the directory contains the files from the /etc directory.
[root@servera backuptest]#ls -ltotal 12 drwxr-xr-x. 95 root root 8192 Feb 8 10:16 etc[root@servera backuptest]#cd etc[root@servera etc]#ls -ltotal 1204 -rw-r--r--. 1 root root 16 Jan 16 23:41 adjtime -rw-r--r--. 1 root root 1518 Sep 10 17:21 aliases drwxr-xr-x. 2 root root 169 Feb 4 21:58 alternatives -rw-r--r--. 1 root root 541 Oct 2 21:01 anacrontab ...output omitted...
Exit from servera.
[root@servera backuptest]#exitlogout[student@servera ~]$exitlogout Connection to servera closed.[student@workstation]$
This concludes the guided exercise.