How to install and uninstall software in Centos

Source: Internet
Author: User

Chapter 1 How to know where to install software in linux

Note: The default installation directory of general software is in/usr/local or/opt. You can find it there.

Command name: whereis

Function Description: search for qualified files in a specific directory. The strength of these files should belong to the original code, binary files, or help files.

Syntax format: whereis [-bfmsu] [-B <directory>...] [-M <directory>...] [-S <directory>...] [file...]

Common parameters:

-B only searches for binary files.

-B <directory> searches for binary files only in the Set directory.

-F does not display the path name before the file name.

-M: only find the description file.

-M <directory> searches for description files only in the specified directory.

-S only searches for original code files.

-S <directory> only searches for original code files in the Set directory.
-U searches for files that do not contain the specified type.

Application: # whereis software name --> View the software installation path
# Which software name --> Software running path

First, you must determine whether the Package Manager is installed or the source code.
1. software installed through rpm package manager:
1. rpm package

You can run the following command:

# Run the rpm-ql package name such as rpm-ql gcc to check where all gcc files are installed.

# Rpm-qa | grep package name to check whether the package has been installed,

# Run rpm-qa to view all Installed Package Names

2. deb package

You can run the following command:

# View the gcc file by dpkg-L package name, for example, dpkg-L gcc.
# Dpkg-l | grep package name to check whether a package is installed,

# Dpkg-l: View All packages

2. software installed through source code:
1. If the source code is used for installation, you can specify the installation directory when configuring configure of the source code, it is embodied in the install target (or * install * target, * represents any character) of the Makefile file. For example, the install target of the Makefile file is as follows:
Install-binPROGRAMS: $ (bin_PROGRAMS)
@ $ (NORMAL_INSTALL)
$ (Mkinstalldirs) $ (DESTDIR) $ (bindir)
@ List = '$ (bin_PROGRAMS)'; for p in $ list; do \
If test-f $ p; then \
Echo "$ (INSTALL_PROGRAM) $ p $ (DESTDIR) $ (bindir)/'echo $ p | sed's/$ (EXEEXT) $ // '| sed' $ (transform) '| sed's/$ (EXEEXT )/''";\
$ (INSTALL_PROGRAM) $ p $ (DESTDIR) $ (bindir)/'echo $ p | sed's/$ (EXEEXT) $ // '| sed' $ (transform) '| sed's/$ (EXEEXT )/'';\
Else:; fi ;\
Done
It is a script that copies the executable file to the directory represented by the $ bindir variable. The variable is defined in the Code before Makefile.
Prefix =/usr/local
Exec_prefix =$ {prefix}

Bindir =$ {exec_prefix}/bin
That is, under/usr/local/bin.

2. Finally, if you have already installed it, you can call it directly, depending on its path.


For example, if you use the gcc command, you can use the following command to query the directory location of the gcc command:

[Wade @ mycentos ~] $ Whereis gcc
Gcc:/usr/bin/gcc/usr/lib/gcc/usr/libexec/gcc/usr/share/man/man1/gcc.1.gz

A whereis command is used to query the location.

Chapter 2 management of software installation and uninstallation in Linux

I will introduce software management in linux in the following three parts. The first two parts are the basic introduction and focus, so that you can understand the different methods for managing software in linux. In practice, we recommend that you use apt-get and yum.

When installing software in Windows, you only need to run the software installation program (setup, install, and so on) or unzip the software using a zip file to solve the problem, run the uninstall, unware, and "uninstall" programs to clean up the software and provide a completely graphical operation interface, it's as simple as clicking "Next" with the mouse. Linux systems seem to be different. Many Beginners complain that it is very difficult to install and uninstall software in Linux, not as intuitive as when using Windows. In fact, installing and uninstalling software in Linux is also very simple. There are also installation wizard or unzipping installation methods, except for binary software distribution, there are also many software packages distributed in the form of source code.

The following describes in detail how to install and uninstall these software:

I. Installation and uninstallation of binary distribution software packages

The binary distribution of Linux software refers to the release form of a compiled binary software package. Its advantage is that it is easy to install and use, and its disadvantage is that it lacks flexibility, if the software package is compiled for a specific hardware platform, it cannot be correctly executed on another platform or environment.

1. * binary software package in rpm format

First, go to the Software Directory.

Installation: rpm-ivh *. rpm

Uninstall: rpm-e packgename

Instance:

1. Find the corresponding software package, such as soft. version. rpm, and download it to a local directory;

2. Open a terminal and run the "su-to-root" command on a non-Super administrator terminal;

3. directory where cd soft. version. rpm is located;

4. Input rpm-ivh soft. version. rpm

Note: RPM (RedHat PackgeManager) is a software package manager provided by RedHat. It can be used to install, upgrade, uninstall, verify, and query software packages in rpm format, it is easy to install, and files installed in multiple directories can be deleted during uninstallation. Therefore, it is recommended that you use rpm software packages as much as possible for beginners. In rpm parameters,-I is the installation,-v is the verification, and-h is the use of hashes to display the installation progress ,*. rpm is the file name of the software package (here *. rpm refers *. src. to. (rpm is a file with a suffix). The parameter-e is used to delete a software package. packgename is the package name, which is different from the file name of the software package. It is usually a string located before the version number in the file name, for example, apache-3.1.12-i386.rpm and apache-devel-3.1.12-i386.rpm are the package file names, which are apache and apache-devel. for more rpm parameters, see man rpm.

If you do not like to install or uninstall these software packages on the Character interface, you can use the graphical package management program in X-Window. Now we are doing very well.

2. Binary packages in the form of * .tar.gz/*. tgz and *. bz2

Installation: tar zxvf * .tar.gz or tar yxvf *. bz2

Uninstall: manually delete

Note: The binary software package in the form of * .tar.gz/*. bz2 is packaged with the tar tool and compressed with gzip/bzip2. You can unpack the package directly during installation. For software that only has a single directory after decompression, run the "rm-rf Software Directory Name" command during uninstallation. If the files are scattered in multiple directories, you must manually delete them one by one (a little effort). To know which files are installed in the system during decompression, run the "tar ztvf * .tar.gz"/"tar ytvf *. bz2 "to obtain the list. The tar Parameter z is to call gzip for decompression, x is to unpack, v is to verify, f is to show the result, y is to call bzip2 for decompression, and t is to list the file list of the package. For more parameters, see man tar.

Note: If you prefer graphic interface operations, you can go to Ubuntu to check its package management, which is super convenient.

3. * binary software package in tgz format

Decompress: tar-zxvf soft. tgz

Switch to the directory after decompression: cd soft (ps: Linux shell press the TAB key to automatically complete the file name)

Install: #./soft-*-installer

Uninstall: manually delete the folder where the installation is located

Example: Install myeclipse-8.0.0-linux-gtk-x86.tgz

Unzip: # tar-zxvf myeclipse-8.0.0-linux-gtk-x86.tgz

Unzip to the current installation directory: cd myeclipse-8.0.0-linux-gtk-x86

Installation: #./myeclipse-8-stable-installer

3. provide software packages for the installation program

These software packages provide installation scripts or binary Installation Wizard programs (setup, install, install. sh, etc.), you only need to run it to complete the software installation; while the uninstallation also provides a script or program for reverse installation. For example, SUN's StarOffice software suite uses the setup installer and provides the reverse installation function after the software is installed. Currently, there are few such software packages, because the installation and uninstallation methods are the same as those for Windows software, you do not need to talk about them more.

Ii. Installation and uninstallation of source code distribution software packages

The source code distribution of Linux software refers to the release form of the source code of all programs of the software. You need to compile and install the executable binary code on your own. The advantage is that the configuration is flexible, some functions/modules can be removed or retained at will to adapt to a variety of hardware/operating system platforms and compiling environments. The disadvantage is that it is difficult and is generally not suitable for beginners.

1. * Source code package in the form of src. rpm

Install: rpm-rebuild *. src. rpm

Cd/usr/src/dist/RPMS

Rpm-ivh *. rpm

Uninstall: rpm-e packgename

Note: The rpm-rebuild *. src. rpm command compiles the source code and generates a binary rpm package under/usr/src/dist/RPMS. then install the Binary Package. Packgename is described above.

22.16tar.gz source code package installation method:

1. Find the corresponding software package, such as soft.tar.gz, and download it to a local directory;

2. Open a terminal and run the command su-to convert it to a root user;

3. directory where cd soft.tar.gz is located;

4. tar-xzvf soft.tar.gz // a soft directory is usually generated.

5. cd soft

6../configure -- prefix =/usr/local/soft (specify the installation directory)

7. make

8. make install

Uninstall: run the cd command to enter the compiled software directory, that is, the installation directory.

Execute the reverse installation command: make uninstall or manually delete

3. tar.bz2 source code package installation method:

1. Find the corresponding software package, such as soft.tar.bz2, and download it to a local directory;

2. Open a terminal and su-become the root user;

3. directory where cd soft.tar.bz2 is located;

4. tar-xjvf soft.tar.bz2 // a soft directory is usually generated.

5. cd soft

6../configure -- prefix =/usr/local/soft (specify the installation directory)

7. make

8. make install

Uninstall: run the cd command to enter the compiled software directory, that is, the installation directory.

Execute the reverse installation command: make uninstall or manually delete

Note: It is recommended that you decompress the package and read the instruction file to learn about the installation requirements and modify the compilation configuration when necessary. The source code of some software packages can be uninstalled by using the make install command after compilation and installation. If this function is not provided, the software must be manually deleted. Because the software may install files in multiple directories of the system, it is often difficult to delete the files, you should configure them before compilation, specify the path to which the software will be installed :. /configure -- prefix = directory name. In this way, you can run the "rm-rf Software Directory Name" command to thoroughly uninstall the directory. Compared with other installation methods, it is the most troublesome to compile and install by yourself. In fact, I personally think that fewer and fewer users will use this method in the future. Because there is no need to increase the performance of the current hardware, so much time is wasted.

Installation Directory: Pay attention to the installation directory during the make install command process, or read the readme file in the installation directory. Of course, the best way is to specify the installation directory during the installation process, that is, in. add the parameter -- prefix =/** after the/configure command, for example :. /configure -- prefix =/usr/local/soft, that is, install the software in the soft directory of the/usr/local/path.

Iii. bin document installation:

If the downloaded software name is soft. bin, it is generally an executable document. The installation method is as follows:

1. Open a terminal and su-become the root user;

2. Run the CD command to enter the directory where the source code package is located.

3. chmod x soft. bin

4. Run the./soft. bin // command to install the software. The software is installed in the directory/soft where the source code compressed package is located!

=== How to uninstall: Delete the installation directory selected during installation,

=== It can be specified during installation, similar to windows installation.

Example: to install jdk under the specified directory/usr/java

Note: 1. by default, software such as OpenOffice is installed in CentOS, which requires Java support. By default, JDK environment is installed. If a specific Java environment is required, it is best to permanently delete the default JDK;

2. view the default JDK command: java-version

3. if you delete the default JDK and then install the new jdk, the related software such as openoffice will also be deleted. Therefore, install the new jdk first and then uninstall the default JDK.

* ** Example of how to uninstall the system with the original JDK: (Note that this operation should be executed after the new jdk is installed)

Enter the terminal to view the gcj version: rpm-qa | grep jdk

Expected result:

Jdk-1.7.0_04-fcs.x86_64

Java-1.6.0-openjdk-1.6.0.0-1.49.1.11.4.el6_3.x86_64

Terminal input, uninstall: yum-y remove java java-1.6.0-openjdk-1.6.0.0-1.49.1.11.4.el6_3.x86_64

Wait for the system to uninstall automatically. The terminal displays Complete. The uninstallation is Complete.

First, create a java folder under/usr and put the installation package in the/usr/java directory.
Then enter the directory (select ① or ② one of the two installation methods based on the Installation Package)

① Install jdk-1_6_0_14-linux-i586-rpm.bin files

# Chmod 777 jdk-1_6_0_14-linux-i586-rpm.bin supervisor modified to Executable

#./Jdk-1_6_0_14-linux-i586-rpm.bin accept select yes to agree to the above agreement

# Rpm-ivh jdk-1_6_0_14-linux-i586.rpm configure Select yes until installation is complete

② Install jdk-1_6_0_14-linux-i586.bin files
# Chmod a + x jdk-1_6_0_14-linux-i586.bin grants the current user permission to execute
#. /Jdk-1_6_0_14-linux-i586.bin license at this time will show the JDK installation license agreement, press the space to flip the page, the program will ask you if you agree to the above agreement, of course, agree, enter "yes" and decompress JDK to the current directory. The unzipping progress is displayed on the screen until the installation is complete.

Configure environment variables for jdk

<1> # vi/etc/profile

<2> Add the following lines at the end: note that in linux, the separators configured for environment variables cannot be used; (semicolon), which must be: (colon)

# Set java environment

Export JAVA_HOME =/usr/program/jdk1.6.0 _ 13

Export JRE_HOME =/usr/program/jdk1.6.0 _ 13/jre

Export CLASSPATH =.: $ JAVA_HOME/lib: $ JAVA_HOME/jre/lib

Export PATH = $ JAVA_HOME/bin: $ JAVA_HOME/jre/bin: $ PATH

<3> after adding the preceding content to the vi Editor, save and exit, and execute the following command to make the configuration take effect!

# Chmod + x/etc/profile; add execution permission

# Source/etc/profile; make the configuration take effect

After the configuration is complete, enter java-version in the command line. If the following information appears, the java environment is successfully installed.

Java version "1.6.0 _ 13"

Java (TM) SE Runtime Environment (build 1.6.0 _ 13-b03)

Java HotSpot (TM) Server VM (build 16.3-b01, mixed mode)

After completing the above steps, we have completed JDK installation and configuration in the CentOS system.

Uninstall their own jdk installation method: the installation directory selected during installation to delete the OK command: # rm-rf jdk-1.6.0_13 command to delete JDK, do not forget to delete the configuration file/etc/profile !!!

4. No software installation required:

Some software, such as lumaqq, does not need to be installed. It can be directly run after the built-in jre is decompressed. The download result is lumaqq.tar.gz. The usage is as follows:

1. Open a terminal and su-become the root user;

2. tar-xzvf lumaqq.tar.gz // a directory named LumaQQ is generated in this step.

3. cd LumaQQ

4. chmod x lumaqq // you can run the lumaqq configuration file.

5. You can run lumaqq by using the command./lumaqq, but you need to enter the full path or convert it to the LumaQQ directory generated just now.

6. To ensure that the path can be used without configuration, you can create a lumaqq link in the/bin directory and run the ln-s lumaqq/bin/command, you can start the QQ chat software by entering lumaqq on a terminal at any time.

7. If you want lumaqq to have a Menu item, use the Menu editing tool, such as Alacarte Menu Editor, to configure a Menu item in the LumaQQ directory generated above, of course, you can also directly go to the/usr/share/applications directory and follow the other *. generate your own desktop document in the format of the desktop document.

5. Upgrade the software management method using yum and apt-get.

I have read the above introduction. You will surely feel that it is too troublesome. The following is a feature available in advanced linux, which is too convenient and more convenient than windows, if you have used Ubuntu apt-get, you will feel pretty good. That's convenient.

1. Let's talk about advanced package management such as Redhat yum.

1). Use YUM to install and delete Software

Note: Yum (Yellow dog Updater, Modified) is a Shell front-end Package Manager in Fedora, RedHat, and SUSE. Based on RPM package management, You can automatically download and install the RPM package from the specified server, and automatically handle dependencies. you can install all dependent software packages at a time without the need to download and install them repeatedly.

It is common to add or delete software in the system. yum is also competent for this task, as long as the software is installed by rpm. The installation command is: yum install xxx. yum queries the database to check whether this software package exists. If yes, check its dependency conflict. If no dependency conflict exists, download and install it; if yes, you will receive a prompt asking if you want to install dependencies at the same time or delete conflicting packages. You can make your own judgment. The DELETE command is yum remove xxx. Like the installation command, yum also queries the database and provides a prompt to solve the dependency.

Install software package with YUM

Command: yum install xxx

Use YUM to delete a software package

Command: yum remove xxx

2). Use YUM to query Software Information

We often encounter such a situation, we want to install a software, only know it is related to a certain aspect, but cannot know its name. In this case, the yum query function takes effect. You can use commands such as yum search keyword to search. For example, if you want to install Instant Messenger, but you don't know what it is, you can use commands such as yum search messenger to search, yum searches for all available rpm descriptions and lists all rpm packages related to messeger. Therefore, we may get gaim, kopete, and so on, and select from them. Sometimes we install a package without knowing its purpose. We can use the yum info packagename command to obtain information.

Use YUM to find software packages

Command: yum search

List all installable software packages

Command: yum list

List all updatable software packages

Command: yum list updates

List all installed software packages

Command: yum list installed

List all software packages installed but not in Yum Repository

Command: yum list extras

List the specified software packages

Command: yum list

2. Talk about the advanced package management method apt-get In Ubuntu

In addition to the ease of apt, one of the major advantages of apt-get is that it greatly reduces the chance of a so-called dependency relationship nightmare (dependency hell), even if it falls into a dependency hell, apt-get also provides good assistance to help you escape from the magic cave. Apt-get is usually found together with online compressed packages, which can be downloaded or installed from the Internet. There are more than 200 official debian images around the world, and a wide range of unofficial software packages provide websites. Different Debian-based release versions are used. The software repository you use may need to be manually selected or set automatically. You can get a complete list of images from the Debian official website. Many unofficial websites provide unofficial software packages for various special purposes. Of course, using unofficial software packages poses more risks. Software packages are prepared for a basic Debian release (from unstable to stable) and divided into different categories (such as main contrib nonfree ), this is based on the debian Free Software Program (also known as dfsg), because the United States restricts the export of encryption software, there is also a non-us category.

Apt installation:

1. Open a terminal and su-become the root user;

2. apt-cache search soft Note: soft is the name or related information of the software you are looking.

3. If soft. version is found in 2, run the apt-get install soft. version command to install

Install software Note: as long as you can access the Internet, you only need to use apt-cache search to find the software and use apt-get

Install software

Common APT Command Parameters

Apt-cache search package

Apt-cache show package obtains package information, such as description, size, and version.

Sudo apt-get install package installation package

Sudo apt-get install package--reinstall re-installation package

Sudo apt-get-f install fix and install "-f = -- fix-missing"

Sudo apt-get remove package Delete package

Sudo apt-get remove package--purge delete a package, including deleting a configuration file.

Sudo apt-get update source sudo apt-get upgrade update installed packages

Sudo apt-get dist-upgrade System

Sudo apt-get dselect-upgrade using dselect

Apt-cache depends package for dependency usage

Apt-cache rdepends package is used to check which packages are dependent on this package.

Sudo apt-get build-dep package installation-related compilation environment

Apt-get source package download the source code of the package

Sudo apt-get clean & sudo apt-get autoclean clear useless packages

Sudo apt-get check whether any corrupted dependency exists

Reference: http://soft.chinabyte.com/ OS /85/12332085.shtml

6. How to execute the software after installation. After installing the software, you can execute the software in multiple ways:

A. After some software is installed, the shortcut keys are automatically added to the Application List. Just like windows, you can find them there.

B. if it cannot be found in the Application List, you can directly enter the command in the/start/Run Command: the startup command is generally the software name, such as firefox, realplay, xmms, etc.

C. Open a shell terminal and enter the software name, which is the same as running the command. If you do not know the entire command process, you can enter a letter that begins with the command and press the tab key to search. The system will automatically display all the commands that start with the input letter/

D. You can run the Startup File directly in the installation directory. the executable icon in Linux is similar to the shell terminal icon.

E. Find the installed software startup file in the/usr/bin directory and run the command. In Linux, All executable file commands are enabled in the/usr/bin directory. You can go to the directory to find the startup command for the file you installed and double-click it.

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.