MTC logo MTC logo Midlands Technical College
Prospective StudentsEnrolled StudentsFaculty & StaffCommunity Partners
About
Academics
Continuing Education
Distance Learning
Student Forms
Library
Class Schedule
News & Updates
Calendar
Directory
Site Map
Ask MTC
MTC Jobs Bookstore
Home
navigation
 
Search

 

About MTC Academics Continuing Education Distance Learning Student Forms Library Class Schedule News & Updates Calendar Directory Site Map Ask MTC MTC Jobs Bookstore Home


CPT 247


Quick Reference

Exercise

Shellscript1

 

Unix Utilities : cpio    tar

Utilities :   cpio  : use the cpio to copy files an directories into and out of archive files

Copy in   mode :  -i

Copy out mode:  -o

Exercise :

1. Create a new directory named testing    mkdir testing

2. Create several new files using the touch command

         touch f1      touch f2    touch f3   touch z1  touch z2 

3.   ls | cpio –o  myarchive.cpio             takes all the files and place them in the archive file named myarchive.cpio

4. Remove some existing files     rm  f1   ;   rm  f2 

5. Restore the missing files        cpio  –it < myarchive.cpio

    t = table of contents of the archived file

If you want to rename the files during the restore process  

cpio –ir < myarhcive.cpio

 

Utility tar  tape archive  to copy files into tape

Exercise : since we do not have tapes for each student, we will redirect the output to a file instead.

1. Archive a set of file     tar c      (create)

     tar   c    mf1  mf2  mz1  mz2 > file1.tar

2. Remove files mf1 mf2     rm mf1  mf2

3.  Restore files      tar x   (extract)

    tar  x  mf1  mf2  <  file1.tar