Introduced
This paper introduces several methods of software installation in Ubuntu, and the use of apt,dpkg tools.
First, the software installation on Linux
Typically, there are three main ways to install software on Linux:
- Online installation
- Installing the Deb package from disk
- Installing from a binary package
- Compiling the installation from source code
There are several ways to install these, and most packages release software in a variety of way, so we often need to master these kinds of software installation methods in order to adapt to various environments. Here are the top three ways to install and install from the source code you will learn in Linux programming.
Second, on-line installation
Imagine, usually when we use Windows, want to install a software, we need to download the corresponding software installation package on the Internet, and then install the time is to continue to click on the next step, these processes must have experienced countless back, but under Linux, a command plus enter, wait for , the software is installed, which is the convenient way to install the software online. Before learning this type of installation, it is important to note that there are some differences between the online installation methods on different Linux distributions, including the commands used and their package management tools, because our development environment is based on Ubuntu, So the online installation that we're dealing with here will only apply to Ubuntu distributions, or other Ubuntu-based distributions such as Ubuntukylin in the country, Ubuntu is a Debian-based release, and it uses Debian's package management tools dpkg, So some operations are also available with Debian. Other distributions such as Redhat,centos,fedora, which use other package management tools, will not be available (Redhat and CentOS using RPM).
1. Try it first
For example, we want to install a software, called w3m
(w3m is a command line of the simple Web browser), then enter the following command:
$ sudo apt-get install w3m
You should see this in the previous chapters many times, which means that a software package named will be installed w3m
Let's take a look at the effect of command execution:
$ w3m www.shiyanlou.com/faq
Note : If you do not immediately use the key to complete the command after installing a software, Tab
you can try to do it first source ~/.zshrc
, then you can use the completion action.
2. Apt Package management tool Introduction
APT is the abbreviation for the Advance Packaging tool (advanced packaging tools) and is the package manager for Debian and its derived distributions, and apt can automatically download, configure, install binary or source-code packages, thus simplifying the process of managing software on UNIX systems. Apt was originally designed as the front end of the dpkg to handle packages in the Deb format. Now that the APT-RPM organization has been modified, APT can be installed in the RPM-enabled system management RPM package. This Package Manager contains apt-
several tools to start with, such as, for apt-get
apt-cache
apt-cdrom
use in the release of the Debian series.
When you perform the installation, the apt-get
tool will first search the local database for information about the w3m
software and download the software installation on the relevant server based on that information, and here are a few questions: Since the software is installed online, Why search in a local database? To explain the problem, you have to mention a few nouns:
- Software source mirror server
- Software source
We need to download a list of packages from the server on a regular basis, using sudo apt-get update
commands to keep the list of local packages up-to-date (sometimes you also need to do this manually, such as replacing a software source), and this table will have a record of software-dependent information, for software dependencies, Let me give an example: when we install the w3m
software, and this software needs libgc1c2
this package to work properly, this time when apt-get
installing the software will be installed for us, in order to ensure that w3m
the normal work.
3.apt-get
apt-get
Using the various common assemblies used to process apt
packages, we can use it to install, uninstall, and upgrade packages online, and some of the common tools that are included are listed below apt-get
:
Tools |
Description |
install |
followed by a package name for installing a package |
update |
Download/update the list of packages used to update the local software source from the software source mirror server |
upgrade |
Upgrade all locally updatable packages, but will not be upgraded if there is a dependency problem, and will usually be executed once before the updateupdate |
dist-upgrade |
Resolve Dependencies and upgrade (there is a risk) |
remove |
Remove installed packages, including packages that are dependent on the removed package, but do not contain a configuration file for the package |
autoremove |
Remove packages that were previously dependent on other packages but are no longer being used |
purge |
Same as remove, but completely removes the package, including its configuration file |
clean |
Remove the installed packages that are downloaded to the local, which are saved by default in/var/cache/apt/archives/ |
autoclean |
Remove older versions of installed software packages |
The following are some apt-get
common parameters:
Parameters |
Description |
-y |
It is useful to use this parameter in some automated installation scripts to automatically respond to the option to install packages. |
-s |
Analog installation |
-q |
Silent installation, specifying multiple q or -q=# , #表示数字, to set the level of silence, which is useful when you do not want to have too much screen output when you install a package |
-f |
Repairing a corrupted dependency |
-d |
Download-Only not installed |
--reinstall |
Reinstall installed packages that may have problems |
--install-suggests |
Install the recommended package installed by apt at the same time |
4. Install the Package
As for the installation, as demonstrated earlier, you just have to do apt-get install <软件包名>
it, and in addition to that, you should be able to reinstall the package. A lot of times we need to reinstall a package, such as your system is compromised, or some bad configuration causes the software to not work properly.
You can reinstall it in the following ways:
$ sudo apt-get --reinstall install w3m
The other one you need to know is how to install the package without knowing the full name of it. Usually we use the Tab
key to complete the package name, and later we will describe a better way to search for the package. Sometimes you need to install multiple packages at the same time, and you can use regular expressions to match package names for batch installations.
5. Software upgrades
# 更新软件源$ sudo apt-get update# 升级没有依赖问题的软件包$ sudo apt-get upgrade# 升级并解决依赖关系$ sudo apt-get dist-upgrade
6. Uninstalling the Software
If you now feel that w3m
this software does not fit your appetite, or is found to be better, you need to uninstall it, then simple! Also is a command plus carriage return sudo apt-get remove w3m
, the system will have a confirmed operation, then the software is "gone".
Or, you can perform
# 不保留配置文件的移除$ sudo apt-get purge w3m# 或者 sudo apt-get --purge remove# 移除不再需要的被依赖的软件包$ sudo apt-get autoremove
7. Software Search
When you just know a software, want to download the use, need to confirm the software warehouse inside there is no, you need to use the search function, the command is as follows:
sudo apt-cache search softname1 softname2 softname3……
apt-cache
command is a tool for local data related operations, as the search
name implies in the local database to find relevant softname1
softname2
... Information about the relevant software. Now let's try to search for the software we installed before w3m
,
The results show 4 w3m
related software and a brief introduction to the relevant software.
We've introduced so much about installing online, and for more information about APT, you can refer to:
Iii. Introduction to installing the Deb package from a local disk using dpkg 1.dpkg
Dpkg is the foundation of the Debian Package Manager, which was created in 1993 by Ian Murdock. The dpkg is very similar to RPM and is also used to install, unload, and supply information related to. deb packages.
Dpkg itself is a bottom-level tool. The upper-level tools, like APT, are used to remotely retrieve packages and handle complex package relationships. "Dpkg" is a shorthand for "Debian package".
We often have packages that can be packaged in a simple form on the web deb
and need to be dpkg
installed with commands.
dpkg
Common Parameters Introduction:
Parameters |
Description |
-i |
Install the specified Deb package |
-R |
followed by a directory name for installing all of the Deb installation packages in this directory |
-r |
Remove, removing an installed package |
-I |
Displaying deb information about a package file |
-s |
Display information for installed software |
-S |
Search for installed Packages |
-L |
Display directory information for installed packages |
2. Install the Deb package using dpkg
We first use the apt-get
plus -d
parameter only download not installed, download the Emacs Editor's Deb package, after the download is complete, we can view the contents of the/var/cache/apt/archives/directory, such as:
Then we'll copy the first one deb
to the home directory and use the dpkg
installation
$ cp /var/cache/apt/archives/emacs24_24.3+1-4ubuntu1_amd64.deb ~# 安装之前参看deb包的信息$ sudo dpkg -I emacs24_24.3+1-4ubuntu1_amd64.deb
As you can see, this package also relies on a few packages, which means that if the host does not currently have these dependent packages, the direct use of the DPKG installation may have some problems because the dpkg
dependencies cannot be resolved for you.
# 使用dpkg安装$ sudo dpkg -i emacs24_24.3+1-4ubuntu1_amd64.deb
As expected, here you may have some errors:
How we're going to fix this error, it's going to work apt-get
, use its -f
parameters, fix the dependency installation
-f install
Without any errors, so that we install successfully, then you can run the Emacs program
3. View the installation directory for installed packages
If you're still struggling with where Linux installs the software, then luckily you'll be able to dpkg
find the answer
Use dpkg -L
View deb
package directory information
$ sudo dpkg -L emacs
dpkg
There are some other parameters that you will learn here as exercises.
Iv. installing from a binary package
Binary package installation is relatively simple, all we need to do is to unzip the binary package downloaded from the network and put it into the appropriate directory, and then add the directory containing the executable main program files into the PATH
environment variable, if you do not know where to put, please review the fourth section about Linux The contents of the directory structure.
Getting Started with Linux basics----Linux Software Installation