Linux RPM, tar package management

Source: Internet
Author: User
Tags bz2 rar syslog

I. Use of RPM PACKAGE commands

RPM has 5 basic operating modes: Install, uninstall, refresh, upgrade and inquire. The following are described separately.

1. Install the Package

Command syntax:

RPM-IVH [RPM Package file name]

The meanings of the parameters in the command are as follows:

-I: Represents the installation package.

-V: Indicates that detailed information is displayed during the installation process.

-H: Indicates horizontal progress is displayed.

Example 1: Install the SQLDEVELOPER-4.0.1.14.48-1.NOARCH.RPM package.

[Email protected] ~]# RPM-IVH sqldeveloper-4.0.1.14.48-1.noarch.rpm

Preparing ... (100########################################### [100%]

1:sqldeveloper (1########################################### [100% ]

[Email protected] ~]#

If the same version of a package is already installed, the system displays the following information.

[Email protected] ~]# RPM-IVH sqldeveloper-4.0.1.14.48-1.noarch.rpm

Preparing ... (100########################################### [100%]

Package Sqldeveloper-4.0.1.14.48-1.noarch is already installed

Example 2: The package is still installed if the package sqldeveloper-4.0.1.14.48-1.noarch.rpm is installed.

If you still intend to install the same version of the package if the package is already installed, you can use the "--replacepkgs" option to ignore the error.

[Email protected] ~]# RPM-IVH--replacepkgs sqldeveloper-4.0.1.14.48-1.noarch.rpm

Preparing ... (100########################################### [100%]

1:sqldeveloper (1########################################### [100% ]

[Email protected] ~]#

2. Uninstalling the Package

Command syntax:

RPM-E [RPM Package name]

The parameters in the command have the following meanings.

-E: Means uninstalling the package.

[Email protected] ~]# rpm-e sqldeveloper

[Email protected] ~]#

Note: Use the package name Sqldeveloper instead of the package name when uninstalling the package sqldeveloper-4.0.1.14.48-1.noarch.rpm

You will also encounter dependency errors when uninstalling packages. Dependency errors occur when another installed package relies on a user attempting to remove a package.

To make RPM ignore this error and force the package to be removed, you can use the "--nodeps" option, but the package that depends on it may not work correctly.

3. Querying packages

Use the "rpm-q" command to query for information about package installation.

(1). Query the details of the specified package.

Command syntax:

Rpm-q [RPM Package name]

Example 1: Check if the Sqldeveloper package is installed

[Email protected] ~]# rpm-q sqldeveloper

Sqldeveloper-4.0.1.14.48-1.noarch

[Email protected] ~]#

Description already installed

(2) Query the system for all installed RPM packages

Command syntax:

Rpm-qa

Example 1: Query all installed Yun packages within the system.

[Email protected] ~]# Rpm-qa yum*

Yum-plugin-security-1.1.30-14.el6.noarch

Yum-plugin-aliases-1.1.30-14.el6.noarch

Yum-rhn-plugin-0.9.1-40.el6.noarch

Yum-metadata-parser-1.1.2-16.el6.x86_64

Yum-plugin-changelog-1.1.30-14.el6.noarch

Yum-plugin-verify-1.1.30-14.el6.noarch

Yum-3.2.29-30.el6.noarch

Yum-plugin-downloadonly-1.1.30-14.el6.noarch

Yum-plugin-versionlock-1.1.30-14.el6.noarch

Yum-utils-1.1.30-14.el6.noarch

Yum-presto-0.6.2-1.el6.noarch

Yum-plugin-tmprepo-1.1.30-14

(3) query Specifies the description of the installed package

Command syntax:

Rpm-qi [RPM Package name]

Example: Query the description information for the Sqldeveloper package.

[Email protected] ~]# Rpm-qi sqldeveloper

Name:sqldeveloper Relocations: (not relocatable)

version:4.0.1.14.48 Vendor: (None)

Release:1 Build date:tue 03:15:58 PM PST

Install date:wed Jan 05:56:15 AM PST Build Host:slc04qag.us.oracle.com

Group:developer Source rpm:sqldeveloper-4.0.1.14.48-1.src.rpm

size:299716358 license:oracle

Signature: (None)

Summary:oracle SQL Developer

Description:

Oracle SQL Developer is a new, free graphical tool that enhances productivity and simplifies database development tasks. With SQL Developer, you can browse database objects, run SQL statements and SQL scripts, and edit and debug PL + SQL Stateme Nts. You can also run any number of provided reports, as well as create and save your own.

[Email protected] ~]#

(4). Query the list of files included in an installed package

Command syntax:

RPM-QL [Package name]

(5). Query the dependency requirements of the package.

Command syntax:

RPM-QR [RPM Package name]

Example: Querying the dependencies of a package.

[Email protected] ~]# RPM-QR sqldeveloper

/bin/sh

Rpmlib (compressedfilenames) <= 3.0.4-1

Rpmlib (filedigests) <= 4.6.0-1

Rpmlib (payloadfileshaveprefix) <= 4.0-1

Rpmlib (PAYLOADISXZ) <= 5.2-1

[Email protected] ~]#

(6). The query system specifies which package the file belongs to.

Command syntax:

RPM-QF [file name]

Example: Querying the/usr/local/bin/sqldeveloper file belongs to that package.

[Email protected] ~]# Rpm-qf/usr/local/bin/sqldeveloper

Sqldeveloper-4.0.1.14.48-1.noarch

[Email protected] ~]#

When specifying a file, you must specify the full path to the file (for example,/usr/local/bin/sqldeveloper)

Two. Tar package management

Use the TAR command to package or compress files and directories for backup purposes.

The most common compressed files under Windows systems are the zip and rar,linux systems, which have. gz,. tar.gz, Tgz, bz2,. Z,. Tar and many other compressed file names, in addition to the. zip and. rar under Windows System can also be used under Linux.

The most common packaging program under Linux is tar, which is called a tar package, and the tar package file commands usually end in. Tar. Once the tar package is generated, it can be compressed with other programs.

1.tar Package usage and management

Command syntax:

[Email protected] ~]# tar--help

Usage:tar [OPTION ...] [FILE] ...

GNU ' tar ' saves many files together into a single tape or disk archive, and can

Restore individual files from the archive.

Examples:

TAR-CF Archive.tar Foo Bar # Create Archive.tar from Files foo and bar.

TAR-TVF Archive.tar # List All files in Archive.tar verbosely.

TAR-XF Archive.tar # Extract all files from Archive.tar.

Main operation mode:

-A,--catenate,--concatenate append tar files to an archive

-C,--create create a new archive

-D,--diff,--compare find differences between archive and file system

--delete Delete from the archive (not on Mag tapes!)

-R,--append append files to the end of an archive

------------------------------------

------------------------------------

------------------------------------

Example 1: Back up all files in the/root directory, the backup file name is Root.bak.tar.

[Email protected] ~]# tar cvf root.bak.tar/root/*

Tar:removing leading '/' from member names

/root/a

/root/anaconda-ks.cfg

/root/b/

/root/b/ccc

/root/desktop/

/root/desktop/gnome-terminal.desktop

/root/documents/

/root/downloads/

/root/install.log

/root/install.log.syslog

/root/music/

/root/pictures/

/root/public/

/root/sqldeveloper-4.0.1.14.48-1.noarch.rpm

/root/templates/

/root/videos/

/root/yang

[Email protected] ~]#

[[email protected] ~]# ls

A Install.log sqldeveloper-4.0.1.14.48-1.noarch.rpm

Anaconda-ks.cfg Install.log.syslog Templates

b Music Videos

Desktop Pictures Yang

Documents Public

Downloads Root.bak.tar

[Email protected] ~]#

You can see that Root.bak.tar is the file that is generated after packaging.

Example 2: View the contents of the Root.bak.tar backup file and display it on the monitor.

[Email protected] ~]# tar TVF root.bak.tar

-r--r--r--root/newuser 0 2015-01-19 05:19 root/a

-RW-------root/root 2623 2014-06-02 14:28 root/anaconda-ks.cfg

Drwxr-xr-x newuser/newuser 0 2015-01-20 05:52 root/b/

-rw-r--r--newuser/newuser 0 2015-01-20 05:52 ROOT/B/CCC

Drwxr-xr-x root/root 0 2014-06-03 17:39 root/desktop/

-rwxr-xr-x root/root 6333 2014-06-03 17:39 root/desktop/gnome-terminal.desktop

Drwxr-xr-x root/root 0 2014-06-02 06:42 root/documents/

Drwxr-xr-x root/root 0 2014-06-02 06:42 root/downloads/

-rw-r--r--root/root 40730 2014-06-02 14:27 root/install.log

-rw-r--r--root/root 9272 2014-06-02 14:19 root/install.log.syslog

Drwxr-xr-x root/root 0 2014-06-02 06:42 root/music/

Drwxr-xr-x root/root 0 2014-06-02 06:42 root/pictures/

Drwxr-xr-x root/root 0 2014-06-02 06:42 root/public/

-rw-r--r--root/root 230725684 2014-04-02 20:18 root/sqldeveloper-4.0.1.14.48-1.noarch.rpm

Drwxr-xr-x root/root 0 2014-06-02 06:42 root/templates/

Drwxr-xr-x root/root 0 2014-06-02 06:42 root/videos/

-rw-r--r--root/root 2014-12-15 05:12 Root/yang

You can see that the package file is packaged by all the files in the root directory.

Example 3: Extract the packaged files.

[Email protected] ~]# tar xvf root.bak.tar

root/a

Root/anaconda-ks.cfg

root/b/

Root/b/ccc

root/desktop/

Root/desktop/gnome-terminal.desktop

root/documents/

root/downloads/

Root/install.log

Root/install.log.syslog

root/music/

root/pictures/

root/public/

root/sqldeveloper-4.0.1.14.48-1.noarch.rpm

root/templates/

root/videos/

Root/yang

[Email protected] ~]#

Example 4: Add the file/root/a to the Root.bak.tar package.

[Email protected] ~]# tar rvf root.bak.tar A

A

[Email protected] ~]# tar TVF root.bak.tar

-r--r--r--root/newuser 0 2015-01-19 05:19 root/a

-RW-------root/root 2623 2014-06-02 14:28 root/anaconda-ks.cfg

Drwxr-xr-x newuser/newuser 0 2015-01-20 05:52 root/b/

-rw-r--r--newuser/newuser 0 2015-01-20 05:52 ROOT/B/CCC

Drwxr-xr-x root/root 0 2014-06-03 17:39 root/desktop/

-rwxr-xr-x root/root 6333 2014-06-03 17:39 root/desktop/gnome-terminal.desktop

Drwxr-xr-x root/root 0 2014-06-02 06:42 root/documents/

Drwxr-xr-x root/root 0 2014-06-02 06:42 root/downloads/

-rw-r--r--root/root 40730 2014-06-02 14:27 root/install.log

-rw-r--r--root/root 9272 2014-06-02 14:19 root/install.log.syslog

Drwxr-xr-x root/root 0 2014-06-02 06:42 root/music/

Drwxr-xr-x root/root 0 2014-06-02 06:42 root/pictures/

Drwxr-xr-x root/root 0 2014-06-02 06:42 root/public/

-rw-r--r--root/root 230725684 2014-04-02 20:18 root/sqldeveloper-4.0.1.14.48-1.noarch.rpm

Drwxr-xr-x root/root 0 2014-06-02 06:42 root/templates/

Drwxr-xr-x root/root 0 2014-06-02 06:42 root/videos/

-rw-r--r--root/root 2014-12-15 05:12 Root/yang

-r--r--r--Root/newuser 6 2015-01-21 06:49 A

[Email protected] ~]#

Three. Special use of tar packages

Tar can call other compression programs while packaging or unpacking, such as calling Gzip,bzip, and so on.

1.tar Call gzip

Gzip is a compression program developed by the GNU organization, and the file ending with. GZ is the result of gzip compression. The decompression program corresponding to gzip is called gzip using the parameter "Z" in Gunzip,tar, as illustrated below.

Example 1: The/ROOT/ABC directory including its subdirectories are all backup files, and compression, the file name is abc.tar.gz.

[Email protected] ~]# tar zcvf abc.tar.gz/root/a

Tar:removing leading '/' from member names

/root/a

[Email protected] ~]#

Example 2: View the contents of the compressed file abc.tar.gz and display it on the monitor.

[Email protected] ~]# tar ZTVF abc.tar.gz

-r--r--r--Root/newuser 6 2015-01-21 06:49 root/a

[Email protected] ~]#

You can see that the compressed file is compressed by a directory and 3 files in that directory.

Example 3: Unzip the compressed file abc.tar.gz.

[Email protected] ~]# tar zxvf abc.tar.gz

root/a

[Email protected] ~]#

2.tar Call bzip2

BZIP2 is a more compressed compression program, and the file ending with. bz2 is the result of bzip2 compression. The decompression program corresponding to the BZIP2 is BUNZIP2. Use the parameter "J" in Tar to invoke Gzip, as illustrated below.

Example 1: Compress directory/root/a and all files in this directory into a abc.tar.bz2 file.

[Email protected] ~]# tar cjf abc.tar.bz2/root/a

Tar:removing leading '/' from member names

[[email protected] ~]# ls

A Downloads root

ABC.TAR.BZ2 Install.log Root.bak.tar

Anaconda-ks.cfg Install.log.syslog sqldeveloper-4.0.1.14.48-1.noarch.rpm

b Music Templates

Desktop Pictures Videos

Documents Public Yang

[Email protected] ~]#

Example 2: View the contents of the compressed file abc.tar.bz2 and display it on the monitor.

[Email protected] ~]# tar TJF abc.tar.bz2

root/a

[[Email protected] ~]

Linux RPM, tar package management

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.