Install and manage Linux applications

Source: Internet
Author: User

Install and manage Linux applications

Composition of Linux applications
1. Common executable program files are generally stored in the/usr/bin directory and can be executed by common users.
2. server programs and management program files are generally stored in the/usr/sbin directory and can be executed by administrators.
3. The configuration file is generally stored in the/etc directory. a subdirectory is created when many configuration files exist.
4. log files are generally stored in the/var/log directory.
5. Application reference documents and other data are generally stored in the/usr/share/doc/directory.
6. The man manual page of the execution file and configuration file is generally stored in the/usr/share/man directory.

Package encapsulation type
1. RPM software package: the file extension of this software package is ". rpm" and can only be installed in a Linux operating system using the RPM mechanism. RPM packages are generally customized for specific versions of the system, so they are highly dependent. To install the RPM package, run the rpm command.

2. DEB software package: the file extension of this software package is ". deb". It can only be installed in a Linux operating system using the DPKG mechanism. To install the DEB software package, you must use the dkpg command in Linux.

3. source code package: this software package is the original code developed by the programmer. It is generally made into a compressed package file in the format of ".tar.gz", ".tar.bz2", because most of them are packaged using tar commands, it is often called "TarBall ". To install source code packages, you must use corresponding compilation tools. Most Linux systems have basic compiling environments, so you must use the source code packages more flexibly.

4. software packages that provide installation programs: these software packages have different extensions, but are still mostly in the TarBall format. The package provides executable programs or script files for installation, such as install. sh and setup. You only need to run the installation file to complete the installation according to the wizard.

5. Green installation-free software packages: these software packages directly contain compiled execution program files, so no special installation is required.

Most of the software packages included in the CD of the RHEL6 system are organized in the Server directory. Through the files in this directory, You can familiarize yourself with the general naming format of the RPM software package. The command for attaching a CD is as follows (assuming that sss. rpm is an application package ):
# Mount/dev/cdrom/media/
# Ls-ls/media/Server/sss. rpm

Use RPM package management tools and commands

The RPM software package management mechanism was first proposed by Red Hat. Later, with the upgrade of the version, it gradually integrated more outstanding features and became the software package management standard for many workers in Linux distributions.

The software package files encapsulated by the RPM mechanism have a conventional naming format. Generally, the file name format of "Software name-software version-release times. hardware platform type. rpm" is used.

The rpm command can be used to manage almost all RPM software packages. Run the "man rpm" command to view help information about the rpm command.

1. query RPM software package information

Rpm-qa

 

Rpm-qa | grep httpd

Rpm-qa | grep gcc

 

Common Parameters

-Qa: displays the list of all software installed in RPM mode in the current system.

-Qf: check which software package is installed in the specified file or directory.

-Qd: displays the list of documents (-- docfiles) installed by the specified software package in the current system.

 

2. Install, upgrade, and uninstall the RPM Software Package

-I: Install a new RPM package in the current system.

-E: uninstall the software package with the specified name.

-U: Check and upgrade a software package in the system. If the software package is not installed, it is equivalent to the "-I" option.

-F: Check and update a software package in the system. If the software package is not installed, discard the installation.

-H: the installation process is displayed with "#" during installation or upgrade of the software package.

-V: displays detailed information during software installation.

For more options, see man.

 

During the installation package, pay attention to the U option. This will upgrade the linux kernel and may cause linux to fail to start.


Run the following command to install rpm:

Rpm-ivh sss. rpm

Rpm-ivh -- force sss. rpm -- force install the software package, but 70% may be difficult to use after installation;

Rpm-ivh -- nodeps sss. rpm software dependency is ignored during installation;

 

Delete the RPM package:

Rpm-e sss --- do not include an extension during Deletion

Rpm-ivh sss. rpm

Rpm-ivh -- force sss. rpm: The software package is forcibly installed, but 70% may be hard to use after installation;

How to solve the circular dependency of software package installation?

Put all the software packages in the same directory and run the following command after entering the directory:

Rpm-ivh *. rpm

Rpm-ivh sss. rpm

Rpm-ivh -- force sss. rpm: The software package is forcibly installed, but 70% may be hard to use after installation;

Rpm-ivh -- nodeps sss. rpm software dependency is ignored during installation;
 
3. Maintain the RPM Database
When the RPM database is damaged, use the "-- rebuilddb" or "-- initdb" function of the rpm command to recreate it.

Compile the installer from source code
Modern Linux releases usually use the package management mechanism to package and install the software, which saves the software compilation and installation process and greatly simplifies the installation and use of the Linux system. However, in some cases, you still need to use source code compilation to install new applications for the system. For example:
1. When a newer application is installed
2. the currently installed program cannot meet the application requirements: For applications encapsulated in RPM format, it generally only contains a small part of the functions that can be implemented by the software, and it is difficult for users to modify and customize the software by themselves. After you reconfigure the source code of the program and compile and install the program, you can customize more flexible and rich functions.
3. when adding new features to an application: when you need to make appropriate modifications to the existing application source code to enhance new features, you must also release the source code of the software, modify and re-compile and install the SDK.
Compiling Source Code requires a corresponding development environment. For free software, the gcc compiler is the best choice. Check the compiling environment in the system:

Basic Process of source code compilation and Installation

1. Unpack: the source code is generally in the form of TallBall. Use the tar command to decompress and release the package. In Linux, you can save the source code files of various software to the/usr/src/directory for centralized management, such:

# Tar xzf sss.tar.gz-C/usr/src

2. Pre-compile and makefile

The configuration is usually completed by the "configure" script file in the source code directory. You can execute "./configure -- help" in the source code directory to view specific parameters. The configuration parameters of different programs are different, but the parameters in the form of "-- prefix" are common to most open-source software. This configuration parameter is used to specify the target folder for installation of the software package, if no parameter is specified, the "configure" configuration script uses the default value. If you install application-related files in the same directory, it is very convenient to uninstall the application. Generally, you only need to delete the program folder.

Take MySql as an example, tar.gz/gz tar.bz2

./Configure -- help

-- Prefix =/usr/local/soft

Some library files may be missing in this step. When an error occurs, you must delete the makefile generated when the pre-compilation fails.

Use the rm command to delete the deleted data.

3. Make Compilation

Compilation: the compilation process is mainly based on the configuration information in the Makefile file to compile the source code file, connect it to a binary module file, and execute the program. After the configuration in step 2 is complete, execute the "make" command to complete the compilation. Generally, it takes longer than the configuration step. make 10 is compiled in parallel and the compilation speed is increased. An error occurs in this step, to make clean, delete the binary files in the intermediate state.

4. installation: After compilation, you can run the "make install" command to copy the execution programs, configuration files, help files, and other files of the software to the Linux system, that is, the final installation process of the application.

In the above process, you can also write the compilation and installation steps as a line of command for execution for the sake of simplicity, and use "&" in the middle to match the separation (make & make install)

. Make install

Part 3 has few problems

If the source code is properly installed and debugged, the performance will be improved by 10 times or even dozens of times. Especially for databases and apache services.

This article permanently updates the link address:

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.