Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objective: Create, view, and extract tar archives. Description: In this activity, you use the tar utility to create, view, and extract a tar archive and

Objective: Create, view, and extract tar archives.

Description: In this activity, you use the tar utility to create, view, and extract a tar archive and use its options to name the tar file and view files as they are being archived and extracted.

1. Start VMware Player, and start an openSUSE virtual machine.

2. Open a terminal window. To create a directory, type mkdir Act6-1 and press Enter.

Switch to this new directory by typing cd Act6-1 and pressing Enter. To create three empty files, type touch apple banana orange and press Enter.

3. Type tar -cvf fruit.tar apple banana orange and press Enter to create a tar file named fruit.tar. (Note: Make sure you include a space after fruit.tar.) The file extension .tar is not necessary, but it helps you identify the archive file when viewing a directorys contents.

4. To view the contents of your current directory, type ls -l and press Enter. What is the size of your tar file?

5. To simulate a user deleting files accidentally, type rm apple banana orange and press Enter. View your current directory again by typing ls -l and pressing Enter. Are the apple, banana, and orange test files gone?

6. To list the archive files contents, type tar -tvf fruit.tar and press Enter.

7. To extract the archive files contents, type tar -xvf fruit.tar and press Enter. View your current directory again by typing ls -l and pressing Enter. Are the three test files back? Is the archive file still there?

8. Remove the tar file by typing rm fruit.tar and pressing Enter. Leave the virtual machine running and the terminal window open for the next activity. The archive files contents you listed in Step 6 are called members. The difference between files and members is how they are accessed. For instance, a file is accessed with commands such as ls, cat, more, and so forth, but members can be viewed only with the tar commands -t option. If the members of a tar archive are the files in your home directory, you should not store the archive in your home directory. If something happened to your home directory, you would lose the data and the backup. It is safer to save the tar file to a disk or move it to another location, such as a network drive. Sometimes you need to extract only a few members from an archive, as when a user deletes a file accidentally. The following example shows using the tar utility to extract a member from an archive:

1. tar -tvf fruit.tar

2. -rw-r--r-- martha/users 0 2012-05-01 11:22 apple

3. -rw-r--r-- martha/users 0 2012-05-01 11:22 banana

4. -rw-r--r-- martha/users 0 2012-05-01 11:22 orange

5. tar -xvf fruit.tar apple

6. apple

The command in line 1 lists the members of the fruit.tar archive, displayed in lines 2 through 4. The command in line 5 includes the -x option to specify the member to be extracted (apple, in this case). If you want to extract more than one member, you can use this same option. The following example shows extracting multiple members at once: tar -xvf fruit.tar apple banana orange.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What are the best practices for managing a large software project?

Answered: 1 week ago

Question

How does clustering in unsupervised learning help in data analysis?

Answered: 1 week ago