Guide to Linux Archive Utility Mastery

zhaozj2021-02-16  160

IT's real solby to find this one. I'm just trying to find cpio info to install 10g on an HPUX BOX

Finally, I Use Following Command To Get The Installation Source

CPIO -IDVMC SHIP_REL10_HP64_DB_DISK1.CPIO

CPIO -IDVMC SHIP_REL10_HP64_DB_DISK2.CPIO? ----------------------------------- for your information --- -----------

Guide to Linux Archive Utility Masteryby sheryl Calish

An Introduction to the Effective Use of the Tar, CPIO, AND RPM Facilities for Archiving and Restoring Files

Whether you are a seasoned application developer, a veteran system administrator, or a nascent Linux newbie, the Linux archive utilities have powerful features that provide advantageous information and functionality to a Linux user. Even in the conceivable but inadvisable case that you do not back up your files, you may still encounter one or more of these facilities. For example, if you download an application like Oracle 10g or OpenOffice, you can uncomprehendingly follow the accompanying instructions to uncompress and install a package. While many, including yours truly, In the case.

AS of this Writing, Three Archive Facilities You Are Most Likey TO ENCOUNTER ON Linux Are GNU TAR, GNU CPIO, AND RPM (Red Hat Packet Manager). "TAR" is an abbreviation of 'T'Ape' Ar'chiver; IT WAS originally written for backup onto magnetic tape. Cpio derives its name from "copy input and output" and is similar to tar. First developed by Red Hat and released to the open source community, rpm is a specialized archive facility designed for packaging application software. by way of introduction to these facilities, this article will focus on archiving files on a single-user system. This pretty much implies backing up your / home directory and perhaps some configuration files in the / etc directory, the directories that change regularly and are most difficult to replace if you run into problems. Although it is possible to run a system or data file backup with a facility like tar, neither of these procedures will be covered here, except to mention that, if you are using Oracle Cluster File Sy stem (OCFS) for backup, you will need to go to oss.oracle.com and download the latest tool to enable use of tar for backup of your Oracle database files. If you use a third-party tool for database backup, you may Still Need to do this Because Some Third-Party Database Backup Programs Use Tar.

Working with tar

Archive utilities, such as tar and cpio, are known for their ability to preserve associated file information: directory structure, file contents, ownership and mode (permission) settings (See my previous article, "Guide to Linux File Command Mastery," for. An Explanation of File Access Permissions.

For User-Controlled Backups or Single-User Systems, Tar Seems To Be The Backup Facility of Choice. Its Basic Command Syntax IS: TAR MANDATORY_OPERATION [Options] NameOftarfile.tar File (s) _to_archive

A mandatory_operation is one of eight "Functions Letters" listed on the tar manpage. Exactly one, and only one, of these "operations" must be specified first when you invoke tar. The most common of these operations are --create (-c ), --List (-t), and --extract (-x).

TWO Commonly Used "Options" Are --verbose (-V), Which Prints A List of Files As Tar Processes Them, And - File (-f), Which Specifies The Name of the Archive File. Althought, They area Extremely Important for Eliminating Confusion.

There Are Three Acceptable Formats for Tar Options and Operations: The Short, MNemonic, And Old Formats. The Short Format Uses Single Letters, As Follows:

$ tar -cvf Documents.Tar Documents

Documents /

Documents / ZZ /

Documents / zz / new_file.out

Documents / SampleSQL /

Documents / Samplesql / MKSample8.sql

Documents / SampleSQL / OE8_CRE.SQL

Documents / SampleSQL / OE8_DROP.SQL

Documents / SampleSQL / HR8_CRE.SQL

The Mnemonic Format Uses Long Names Such As

$ tar --create --verbose --file documents.tar documents

To do the same. The old format is Similar To The Short One But Does NOT USE The Preceding Dash:

$ TAR CVF Documents.Tar Documents

Each of the Above Commands Performs The Same Two Tasks:

THEY CREATE A TAR File for the Directory Documents, Which Contains Two Subdirector The Print The Name of Each File As Is Added To the Archive, Documents.tar

One important and often confusing concept is that, unless specified with the -C --directory = DIR option, tar archives are created in the directory in which tar is invoked, the working directory, not the directory of the articles to be tarred.Formats Can Be Intermixed, As with

$ TAR CV - File Documents.tar Documents

For Example. The Order of Options IN A TAR Command Is Important for The Following Command Will Produce An Archive Named "V."

$ tar -cfv archive.tar Documents

Using The Mnemonic Format Can AlleViate Some of this Confusion.

There Are No Requirements for Naming Archives, But by Convention Tar Files Are Named with a * .tar Extensse. Gzipped Archives, Discussed Later, Are USUALLY NAMED * .TAR.GZ or * .tgz.

Peeking Inside your archive

So, Here's Where Things Get Interesting. Once you have peek inside it usding the -t, - list option:

$ tar -tf documents.tar

which will output a listing similar to the one produced when you run tar -cv. It is also a good idea to get a listing of a tar file you have downloaded before you extract it, to make sure that the files do not begin with a "/", indeicating absolute pathnames.

You can look for individual files with tar -t.

$ tar -tf documents.tar documents / samplesql / mk * .sql

Documents / Samplesql / MKSample8.sql

This Approach Also Works for Directories.

$ tar -tf documents.tar Documents / SampleSQL

Documents / SampleSQL /

Documents / Samplesql / MKSample8.sql

Documents / SampleSQL / OE8_CRE.SQL

Documents / SampleSQL / OE8_DROP.SQL

...

Using the -v option with --list produduces a long file listing of your tar company.

$ tar -tvf documents.tar Documents / SampleSQL

Listing tar contents is useful in finding the exact name of a single file you want to extract. You can also see that tar automatically retains the modification date and other file information.To find the differences between an existing tar file and the file system, invoke Tar with the -d, --diff option.

$ tar -dvf documents.tar

Documents / SampleSQL /

Documents / Samplesql / MKSample8.sql

TAR: Documents / SampleSQL / OE8_VIEWS.SQL: WARNING: Cannot Stat: No Such File or Directory

Documents / SampleSQL / HR8_ANALZ.SQL: Mod Time Differs

Documents / SampleSQL / HR8_ANALZ.SQL: Size Differs

Documents / SampleSQL / Getdate.sql

TAR: Documents / SampleSQL / Getdate.sql: Warning: Cannot Stat: No Such File or Directory

...

In this case, tar is reporting that we have one file in our archive, hr8_analz.sql, that differs from the file system version, and two files, oe8_views.sql and getdate.sql, in our tar archive but not in our file system .

Tar Will Ignore Files In The Directory That Have Been Created Since The Archive Was Last Created. However, Updating Your Archive IS Pretty Straightforward, As You Will See in The next section.

Add files to an archive

You can add a new file to an existing archive with the -r, --append option.

$ tar -rvf Documents.Tar Documents / SampleSQL

This Causes the entire directory to be appended to the archive. A Single File Can Be Appended to an Archive with:

$ tar -rvf Documents.tar Documents / SampleSQL / Getdate.sql

Documents / SampleSQL / Getdate.sql

Due to tar's origins as a tool for archiving to tape, updating your archive with --append or --update will simply add modified files to the existing archive without removing the old files. The -N, --newer option can be used to Create Incremental Archives of New and Modified Files. Ultimately, Recreating An Archive ON A Regular Basis May Be The Easiest Way To Maintain An Up-to-Date Archive.Backing Up Lots of Data

For a large amount of data, you can either send tar output to other media, such as tapes, CD-ROMs, or floppy disks, using the -M (--multivolume) option or you can use one of the compression facilities available with Tar. However, You Cannot Use Both Together; Doing So Will Render Your Archive Useless.

Traditional UNIX versions of tar do not support zipping, although archived files could, and still can, be piped to a compression facility With GNU tar, compression can be specified with one of several options when tar is invoked Tar supports three compression alternatives..:

Compress / Uncompress (-z, --compress / - uncompress Gzip / gunzip (-z, --gzip / - gunzip) bzip2 / bunzip2 (-j, --bzip2 / - bunzip2).

According to the GNU Project, compress is an older, proprietary compression utility found in commercial UNIX distributions and is available on Linux for the sake of compatibility Gzip has been available in the GNU version of tar since early 1997;. It can unzip files treated with Compress and is considered a better choice because of the folload:

IT Combines Unix Tar and Compress Commands ITS Use Does Not Subject You to Possible Patent Violations It is considered More Effic Than Compress / Uncompress.

BZIP2 / Bunzip2 is An Alternative Utility That Provides Even More Efficient, Albeit Slower, Compression Than Gzip.

ONCE AN Archive Is CREATED WITH A COMPRESSION FILTER:

$ tar -czvf documents.tar.gz

You Must Run It THROUGH The Filter in All Further References To That Archive. To list the contents of the archive:

$ tar -tzvf documents.tar.gz

To Get a - Diff on The Archive,

$ tar -dzvf documents.tar.gz

OR, To --extract An Archive, As We Will Discuss next.

Extracing a tar archive

You can Extract Whole Directories or Individual Files By Running Tar with The --Extract (-x) Operation.

$ TAR -XVF SampleSql.tar getdate.sql

oral

$ tar -xvf Documents.tar Documents / SampleSQL

......................

$ tar -xzvf articles.tar.gz

$ TAR -XZVF ARTICLES.TAR.GZ * .DOC

ONE CAVEAT: VERIFY WHICH DIRECTORY you are in WHEN You Execute An Extract. You Will Need To Change To The Target Directory (CD) OR Specify It with The -c Option.

Working with cpio

Cpio is tar's predecessor in the UNIX world. Like tar, it archives files to hard disk, floppy, CD-ROM, or tape. It is more versatile than tar in the types of files it handles. The GNU version of cpio copies files into or out of a cpio or tar archive. It recognizes and handles special formats, such as HPUX binary, old ACSII, new ASCII, and a few others. It is also useful for moving an entire directory tree. To be compatible with older cpio programs , CPIO Stores ITS Archive Files in binary format.

The General Format of the Command IS:

CPIO -Mode [other_options] [redirection_symbol] FileName

IT Takes An Exprlicit List of Files from Standard Input, So It Is Typically Used At The End of Pipe That Begins with ls or find.

There are three basic modes in which you can use cpio: The copy-out mode, used with the -o option, copies files to an archive The copy-in mode, used with the -i option, extracts files from an archive The copy -Pass Mode, Used with the -p Option, Passs Files from One Directory Tree To Another.

DiffERENT CPIO OPTIONS Are ALOWABLE Depending. A Full Listing of Options Allowed in Each Mode Is Found in The "Synopsis" section of the cpio manpage.

Copy-Out Mode

Unlike tar, cpio needs explicit instructions: which files to archive with standard output, where to redirect the archive, whether the associated file information should be preserved, and so on Copy-out mode can archive the contents of a directory with.

$ LS | CPIO -OV> Samplesql.cpio

.

You can use the find command to send files to cpio as well.

$ FIND. -PRINT -DEPTH | CPIO -OV> Documents.cpio

To minimize issues with permissions on directories, use the -depth option of find. This option processes the directory contents before the directory itself, allowing the contents of a directory without owner write privileges to be restored before the directory's permissions are restored.

The -t, --list facility is also available with cpio and can even ber on a tar archive.

$ CPIO -TV

Copy-in MODE

Use copy-in mode to extract the contents of an archive. In this mode, cpio automatically recognizes which kind of archive it is reading. This means it can read archives created on machines with a different byte order. $ Cpio -idv <.. /samplesql.cpio

Furthermore, CPIO Differs from TAR I IT WILL NOT RESTORE A File's Original Modification Time Unless: --Preserve-Modification-Time Option:

$ cpio -idvm

As already exercioned, CPIO CAN Extract from a tar archive as well.

$ cpio -idv

Although Cpio Doesn't Work On Zipped Files, You Can Unzip your Files Before Sending The M To CPIO Via a Pipe.

Copy-Pass Mode

This Mode is a combination of the copy-out and copy-in modes. The Major Difence is this it bypasses anotive. It can one to another and is buy one....................... ..

$ FIND. -Depth -Print0 | CPIO - Null-Pvda TestDir

Note the use of the -print0 option with find instead of -print, as we used in copy-out mode. The copy-pass mode of GNU cpio needs files terminated by a null, a service provided by the -print0 option. This approach Allows CPIO to Handle Filenames That Contain A Newline Character And Requires The - Null Option In The CPI Command Above. The CPICAKE-DIRECTORES OPTION DIRECTS CPIO To Create The Directory Testdir.

TAR CAN Accomplish The Same Thing. However, in This Example The Directory TestDir Must Be create first.

$ tar -cvf - Samplesql | (CD TestDir; Tar -xF -)

TAR CAN Accomplish The Same Thing. However, in This Example The Directory TestDir Must Be create first.

$ tar -cvf - Samplesql | (CD TestDir; Tar -xF -)

Here, tar sends the archive to standard output, denoted by the "-" in the first tar command The second tar command gets the archive from standard input, denoted by the. "-". In the second tar command When the files are passed THEY Are Copied to TestDir, Preserve User, Permission, and Date Information.rpm

Both Red Hat and Suse Linux Distributions Use RPM To Install your Linux Operating System and Application Software. It can be used to:

Install All Application Files with a Single Command Manage Your Installed Packages Update A Package Uninstall A Single Command Build A Software Package from Source Code Into Source and Binary Form.

We'll Discuss All But The Last Function Here.

Querying rpm

Use the -q, --quey option to Obtain Information on rpm packages. Combine -q with the -a option to get a list of all rpm packages installed on your system.

$ rpm -qa | more

Or, for a more Ordered Result,

$ rpm -qa | sort | grep k | more

IF you installed a package with cpio, tar, Oracle Universal Installer, OR ANY Other Installation Program, IT Will NOTBIN this list. You can find the version of any rpm installed package with:

$ rpm -q glibc

GLIBC-2.2.5-177

RPM -Qi with a package name provided on a Specific Package:

$ rpm -qi orarun

THIS Commption of the Package. To Find A List of All Files Installed with a package, us:

$ rpm -ql orarun

/etc/init.d/oracle

/etc/profile.d/oracle.csh

...

Before You Go Overboard Spring-Cleaning Your Files, However, It Might Be a Good Idea To Find Out Which Package Uses a Particular File.

$ rpm -qf / usr / sbin / rcoracle

Orarun-1.3-0

Installing, Updating, and Uninstalling with rpm

The -i Option Directs rpm to install a package. $ Rpm -ivh orarun-1.3-0.rpm

Combined with the --h Option, The -i Option Causes rpm to display "#" Symbols as the package is being installed. This lets you know the installation is not hung.

Resources

Download Oracle Database 10g for LinuxOracle Database 10g Release 1 (10.1.0.2) is currently available on Linux x86 and Linux Itanium platforms; download it from OTN for free here Visit the Linux Technology CenterBookmark this page for technical information about Linux sysadmin best practices generally. And the oracle-on-linux stack specifically. related articles archive of linux-limited technical articles

The -V, verify option checks for installation problems. If you try to install a newer version of a package that is already installed, you will get an error message. In this case, you should use the -U option to update a package.

Uninstall an rpm package with the -e option:

$ rpm -e orarun

Sometimees WHEN You Uninstall or Install A Package, you will received one or more missing dependency packages. To View the list of dependencies for a particular package, use the command:

$ rpm -qr orarun

/ bin / sh

. The solution lies...........

$ rpm -e --Nodeps Netscape

As you might guess, this command could cause problems if used indiscriminately. Sometimes, however, it is the only way out. The same holds true for the --force option, which will install a package, in spite of conflicts, by overwriting current Files.

Obtaining archival qualy

While there is some overlap in their functionality, the archive facilities discussed here do have special capabilities. They also have their champions and critics.Both rpm and tar are commonly used for distributing software packages. In addition to its distribution functions, tar is frequently used as a backup utility. For many, however, cpio's simplicity makes it a favorite backup tool. There is also a facility called rpm2cpio, which converts an rpm package into a cpio package, enabling the extraction of one or two files from an rpm package. See "Maximum rpm: taking the red hat package manager to the limit" by Edward C. Bailey for more information.

It is possible to use a combination of tar, cpio, and rpm or other installer to install different software on your system. Most systems probably use an assortment of installation methods for various application programs. However, there is an increased danger of accidental overwriting with This Approach. While Cpio Will Complain About Overwriting a File Unless Explicitly Told To Do So, Tar Will Happily Do So.

Which, then, is the best facility for archiving your files? As with most decisions in information technology, there is no simple answer. Rather, the best solution depends on your requirements, preferences, and policies.

Sheryl Calish

(scalish@earthlink.net) IS An Oracle Developer Specializing. She is also funing chair for the center florida oracle users group and marketing chair for the Ioug Linux sig.

转载请注明原文地址:https://www.9cbs.com/read-8050.html

New Post(0)