SUSE( Software and System Entwicklung,即软件和系统开发。其中‘entwicklung‘是德语,意为开发)Linux 是由 Novell 公司在 Linux 内核基础上建立的操作系统。SUSE Linux 有两个发行分支。其中之一名为 openSUSE,这是一款自由而且免费的操作系统 (free as in speech as well as free as in wine)。该系统由开源社区开发维护,支持一些最新版本的应用软件,其最新的稳定版本为 13.2。
另外一个分支是 SUSE Linux 企业版。该分支是一个为企业及商业化产品设计的 Linux 发行版,包含了大量的企业应用以及适用于商业产品生产环境的特性。其最新的稳定版本为 12。
以下的链接包含了安装企业版 SUSE Linux 服务器的详细信息。
- 如何安装企业版 SUSE Linux 12
Zypper 和 Yast 是 SUSE Linux 平台上的软件包管理工具,他们的底层使用了 RPM(LCTT 译者注:RPM 最初指 Redhat Pacakge Manager ,现普遍解释为递归短语 RPM Package Manager 的缩写)。
Yast(Yet another Setup Tool )是 OpenSUSE 以及企业版 SUSE 上用于系统管理、设置和配置的工具。
Zypper 是软件包管理器ZYpp的命令行接口,可用于安装、删除SUSE Linux上的软件以及进行系统更新。ZYpp为Zypper和Yast提供底层支持。
本文将介绍实际应用中常见的一些Zypper命令。这些命令用来进行安装、更新、删除等任何软件包管理器所能够胜任的工作。
重要 : 切记所有的这些命令都将在系统全局范围内产生影响,所以必须以 root 身份执行,否则命令将失败。
获取基本的 Zypper 帮助信息
# zypper
Usage:
zypper [--global-options]
# zypper help in
或者
# zypper help install
install (in) [options] {capability | rpm_file_uri}
Install packages with specified capabilities or RPM files with specified
location. A capability is NAME[.ARCH][OP], where OP is one
of .
Command options:
--from Select packages from the specified repository.
-r, --repo Load only the specified repository.
-t, --type Type of package (package, patch, pattern, product, srcpackage).
Default: package.
-n, --name Select packages by plain name, not by capability.
-C, --capability Select packages by capability.
-f, --force Install even if the item is already installed (reinstall),
downgraded or changes vendor or architecture.
--oldpackage Allow to replace a newer item with an older one.
Handy if you are doing a rollback. Unlike --force
it will not enforce a reinstall.
--replacefiles Install the packages even if they replace files from other,
already installed, packages. Default is to treat file conflicts
as an error. --download-as-needed disables the fileconflict check.
......
# zypper se gnome-desktop
Retrieving repository 'openSUSE-13.2-Debug' metadata ............................................................[done]
Building repository 'openSUSE-13.2-Debug' cache .................................................................[done]
Retrieving repository 'openSUSE-13.2-Non-Oss' metadata ......................................................... [done]
Building repository 'openSUSE-13.2-Non-Oss' cache ...............................................................[done]
Retrieving repository 'openSUSE-13.2-Oss' metadata ..............................................................[done]
Building repository 'openSUSE-13.2-Oss' cache ...................................................................[done]
Retrieving repository 'openSUSE-13.2-Update' metadata ...........................................................[done]
Building repository 'openSUSE-13.2-Update' cache ................................................................[done]
Retrieving repository 'openSUSE-13.2-Update-Non-Oss' metadata ...................................................[done]
Building repository 'openSUSE-13.2-Update-Non-Oss' cache ........................................................[done]
Loading repository data...
Reading installed packages...
S | Name | Summary | Type
--+---------------------------------------+-----------------------------------------------------------+-----------
| gnome-desktop2-lang | Languages for package gnome-desktop2 | package
| gnome-desktop2 | The GNOME Desktop API Library | package
| libgnome-desktop-2-17 | The GNOME Desktop API Library | package
| libgnome-desktop-3-10 | The GNOME Desktop API Library | package
| libgnome-desktop-3-devel | The GNOME Desktop API Library -- Development Files | package
| libgnome-desktop-3_0-common | The GNOME Desktop API Library -- Common data files | package
| gnome-desktop-debugsource | Debug sources for package gnome-desktop | package
| gnome-desktop-sharp2-debugsource | Debug sources for package gnome-desktop-sharp2 | package
| gnome-desktop2-debugsource | Debug sources for package gnome-desktop2 | package
| libgnome-desktop-2-17-debuginfo | Debug information for package libgnome-desktop-2-17 | package
| libgnome-desktop-3-10-debuginfo | Debug information for package libgnome-desktop-3-10 | package
| libgnome-desktop-3_0-common-debuginfo | Debug information for package libgnome-desktop-3_0-common | package
| libgnome-desktop-2-17-debuginfo-32bit | Debug information for package libgnome-desktop-2-17 | package
| libgnome-desktop-3-10-debuginfo-32bit | Debug information for package libgnome-desktop-3-10 | package
| gnome-desktop-sharp2 | Mono bindings for libgnome-desktop | package
| libgnome-desktop-2-devel | The GNOME Desktop API Library -- Development Files | packag
| gnome-desktop-lang | Languages for package gnome-desktop | package
| libgnome-desktop-2-17-32bit | The GNOME Desktop API Library | package
| libgnome-desktop-3-10-32bit | The GNOME Desktop API Library | package
| gnome-desktop | The GNOME Desktop API Library | srcpackage
# zypper info -t pattern lamp_server
Loading repository data...
Reading installed packages...
Information for pattern lamp_server:
------------------------------------
Repository: openSUSE-13.2-Update
Name: lamp_server
Version: 20141007-5.1
Arch: x86_64
Vendor: openSUSE
Installed: No
Visible to User: Yes
Summary: Web and LAMP Server
Description:
Software to set up a Web server that is able to serve static, dynamic, and interactive content (like a Web shop). This includes Apache HTTP Server, the database management system MySQL,
and scripting languages such as PHP, Python, Ruby on Rails, or Perl.
Contents:
S | Name | Type | Dependency
--+-------------------------------+---------+-----------
| apache2-mod_php5 | package |
| php5-iconv | package |
i | patterns-openSUSE-base | package |
i | apache2-prefork | package |
| php5-dom | package |
| php5-mysql | package |
i | apache2 | package |
| apache2-example-pages | package |
| mariadb | package |
| apache2-mod_perl | package |
| php5-ctype | package |
| apache2-doc | package |
| yast2-http-server | package |
| patterns-openSUSE-lamp_server | package |
# zypper shell
或者
# zypper sh
zypper> help
Usage:
zypper [--global-options]
注意:在 Zypper shell里面可以通过键入 ‘help‘ 获得全局选项以及子命令的列表。
Zypper 软件库管理
列举已定义的软件库
# zypper repos
或者
# zypper lr
| Alias | Name | Enabled | Refresh
--+---------------------------+------------------------------------+---------+--------
1 | openSUSE-13.2-0 | openSUSE-13.2-0 | Yes | No
2 | repo-debug | openSUSE-13.2-Debug | Yes | Yes
3 | repo-debug-update | openSUSE-13.2-Update-Debug | No | Yes
4 | repo-debug-update-non-oss | openSUSE-13.2-Update-Debug-Non-Oss | No | Yes
5 | repo-non-oss | openSUSE-13.2-Non-Oss | Yes | Yes
6 | repo-oss | openSUSE-13.2-Oss | Yes | Yes
7 | repo-source | openSUSE-13.2-Source | No | Yes
8 | repo-update | openSUSE-13.2-Update | Yes | Yes
9 | repo-update-non-oss | openSUSE-13.2-Update-Non-Oss | Yes | Yes
# zypper lr -u
| Alias | Name | Enabled | Refresh | URI
--+---------------------------+------------------------------------+---------+---------+----------------------------------------------------------------
1 | openSUSE-13.2-0 | openSUSE-13.2-0 | Yes | No | cd:///?devices=/dev/disk/by-id/ata-VBOX_CD-ROM_VB2-01700376
2 | repo-debug | openSUSE-13.2-Debug | Yes | Yes | http://download.opensuse.org/debug/distribution/13.2/repo/oss/
3 | repo-debug-update | openSUSE-13.2-Update-Debug | No | Yes | http://download.opensuse.org/debug/update/13.2/
4 | repo-debug-update-non-oss | openSUSE-13.2-Update-Debug-Non-Oss | No | Yes | http://download.opensuse.org/debug/update/13.2-non-oss/
5 | repo-non-oss | openSUSE-13.2-Non-Oss | Yes | Yes | http://download.opensuse.org/distribution/13.2/repo/non-oss/
6 | repo-oss | openSUSE-13.2-Oss | Yes | Yes | http://download.opensuse.org/distribution/13.2/repo/oss/
7 | repo-source | openSUSE-13.2-Source | No | Yes | http://download.opensuse.org/source/distribution/13.2/repo/oss/
8 | repo-update | openSUSE-13.2-Update | Yes | Yes | http://download.opensuse.org/update/13.2/
9 | repo-update-non-oss | openSUSE-13.2-Update-Non-Oss | Yes | Yes | http://download.opensuse.org/update/13.2-non-oss/
# zypper lr -P
| Alias | Name | Enabled | Refresh | Priority
--+---------------------------+------------------------------------+---------+---------+---------
1 | openSUSE-13.2-0 | openSUSE-13.2-0 | Yes | No | 99
2 | repo-debug | openSUSE-13.2-Debug | Yes | Yes | 99
3 | repo-debug-update | openSUSE-13.2-Update-Debug | No | Yes | 99
4 | repo-debug-update-non-oss | openSUSE-13.2-Update-Debug-Non-Oss | No | Yes | 99
5 | repo-non-oss | openSUSE-13.2-Non-Oss | Yes | Yes | 85
6 | repo-oss | openSUSE-13.2-Oss | Yes | Yes | 99
7 | repo-source | openSUSE-13.2-Source | No | Yes | 99
8 | repo-update | openSUSE-13.2-Update | Yes | Yes | 99
9 | repo-update-non-oss | openSUSE-13.2-Update-Non-Oss | Yes | Yes | 99
刷新软件库
# zypper refresh
或者
# zypper ref
Repository 'openSUSE-13.2-0' is up to date.
Repository 'openSUSE-13.2-Debug' is up to date.
Repository 'openSUSE-13.2-Non-Oss' is up to date.
Repository 'openSUSE-13.2-Oss' is up to date.
Repository 'openSUSE-13.2-Update' is up to date.
Repository 'openSUSE-13.2-Update-Non-Oss' is up to date.
All repositories have been refreshed.
# zypper refresh repo-non-oss
Repository 'openSUSE-13.2-Non-Oss' is up to date.
Specified repositories have been refreshed.
# zypper ref -f repo-non-oss
Forcing raw metadata refresh
Retrieving repository 'openSUSE-13.2-Non-Oss' metadata ............................................................[done]
Forcing building of repository cache
Building repository 'openSUSE-13.2-Non-Oss' cache ............................................................[done]
Specified repositories have been refreshed.
修改软件库
本文中我们使用‘zypper modifyrepo‘ 或者 ‘zypper mr‘ 来关闭或者开启 zypper 软件库。
# zypper lr
| Alias | Name | Enabled | Refresh
--+---------------------------+------------------------------------+---------+--------
1 | openSUSE-13.2-0 | openSUSE-13.2-0 | Yes | No
2 | repo-debug | openSUSE-13.2-Debug | Yes | Yes
3 | repo-debug-update | openSUSE-13.2-Update-Debug | No | Yes
4 | repo-debug-update-non-oss | openSUSE-13.2-Update-Debug-Non-Oss | No | Yes
5 | repo-non-oss | openSUSE-13.2-Non-Oss | Yes | Yes
6 | repo-oss | openSUSE-13.2-Oss | No | Yes
7 | repo-source | openSUSE-13.2-Source | No | Yes
8 | repo-update | openSUSE-13.2-Update | Yes | Yes
9 | repo-update-non-oss | openSUSE-13.2-Update-Non-Oss | Yes | Yes
从以上输出的列表中我们可以看到 ‘repo-oss’ 库的标示数字是 6,因此通过以下的命令来关闭该库。
# zypper mr -d 6
Repository 'repo-oss' has been successfully disabled.
# zypper mr -e 6
Repository 'repo-oss' has been successfully enabled.
# zypper mr -rk -p 85 repo-non-oss
Repository 'repo-non-oss' priority has been left unchanged (85)
Nothing to change for repository 'repo-non-oss'.
# zypper mr -Ka
RPM files caching has been disabled for repository 'openSUSE-13.2-0'.
RPM files caching has been disabled for repository 'repo-debug'.
RPM files caching has been disabled for repository 'repo-debug-update'.
RPM files caching has been disabled for repository 'repo-debug-update-non-oss'.
RPM files caching has been disabled for repository 'repo-non-oss'.
RPM files caching has been disabled for repository 'repo-oss'.
RPM files caching has been disabled for repository 'repo-source'.
RPM files caching has been disabled for repository 'repo-update'.
RPM files caching has been disabled for repository 'repo-update-non-oss'.
# zypper mr -ka
RPM files caching has been enabled for repository 'openSUSE-13.2-0'.
RPM files caching has been enabled for repository 'repo-debug'.
RPM files caching has been enabled for repository 'repo-debug-update'.
RPM files caching has been enabled for repository 'repo-debug-update-non-oss'.
RPM files caching has been enabled for repository 'repo-non-oss'.
RPM files caching has been enabled for repository 'repo-oss'.
RPM files caching has been enabled for repository 'repo-source'.
RPM files caching has been enabled for repository 'repo-update'.
RPM files caching has been enabled for repository 'repo-update-non-oss'.
# zypper mr -Kt
RPM files caching has been disabled for repository 'repo-debug'.
RPM files caching has been disabled for repository 'repo-debug-update'.
RPM files caching has been disabled for repository 'repo-debug-update-non-oss'.
RPM files caching has been disabled for repository 'repo-non-oss'.
RPM files caching has been disabled for repository 'repo-oss'.
RPM files caching has been disabled for repository 'repo-source'.
RPM files caching has been disabled for repository 'repo-update'.
RPM files caching has been disabled for repository 'repo-update-non-oss'.
# zypper mr -kt
RPM files caching has been enabled for repository 'repo-debug'.
RPM files caching has been enabled for repository 'repo-debug-update'.
RPM files caching has been enabled for repository 'repo-debug-update-non-oss'.
RPM files caching has been enabled for repository 'repo-non-oss'.
RPM files caching has been enabled for repository 'repo-oss'.
RPM files caching has been enabled for repository 'repo-source'.
RPM files caching has been enabled for repository 'repo-update'.
RPM files caching has been enabled for repository 'repo-update-non-oss'.
增加新的软件库
可以通过这两个 zypper 指令 – ‘zypper addrepo’ 和 ‘zypper ar’ 来增加新的软件库。在此过程中可以使用 URL 或者软件库的别名。
# zypper ar http://download.opensuse.org/update/11.1/ update
Adding repository 'update' .............................................................................................................................................................[done]
Repository 'update' successfully added
Enabled : Yes
Autorefresh : No
GPG check : Yes
URI : http://download.opensuse.org/update/11.1/
# zypper nr 10 upd8
Repository 'update' renamed to 'upd8'.
删除软件库
# zypper rr upd8
# Removing repository 'upd8' .........................................................................................[done]
Repository 'upd8' has been removed.
使用 zypper 进行软件包管理
用 zypper 安装一个软件包
# zypper in MozillaFirefox
Loading repository data...
Reading installed packages...
Resolving package dependencies...
The following 128 NEW packages are going to be installed:
adwaita-icon-theme at-spi2-atk-common at-spi2-atk-gtk2 at-spi2-core cantarell-fonts cups-libs desktop-file-utils fontconfig gdk-pixbuf-query-loaders gstreamer gstreamer-fluendo-mp3
gstreamer-plugins-base gtk2-branding-openSUSE gtk2-data gtk2-immodule-amharic gtk2-immodule-inuktitut gtk2-immodule-thai gtk2-immodule-vietnamese gtk2-metatheme-adwaita
gtk2-theming-engine-adwaita gtk2-tools gtk3-data gtk3-metatheme-adwaita gtk3-tools hicolor-icon-theme hicolor-icon-theme-branding-openSUSE libasound2 libatk-1_0-0 libatk-bridge-2_0-0
libatspi0 libcairo2 libcairo-gobject2 libcanberra0 libcanberra-gtk0 libcanberra-gtk2-module libcanberra-gtk3-0 libcanberra-gtk3-module libcanberra-gtk-module-common libcdda_interface0
libcdda_paranoia0 libcolord2 libdrm2 libdrm_intel1 libdrm_nouveau2 libdrm_radeon1 libFLAC8 libfreebl3 libgbm1 libgdk_pixbuf-2_0-0 libgraphite2-3 libgstapp-1_0-0 libgstaudio-1_0-0
libgstpbutils-1_0-0 libgstreamer-1_0-0 libgstriff-1_0-0 libgsttag-1_0-0 libgstvideo-1_0-0 libgthread-2_0-0 libgtk-2_0-0 libgtk-3-0 libharfbuzz0 libjasper1 libjbig2 libjpeg8 libjson-c2
liblcms2-2 libLLVM libltdl7 libnsssharedhelper0 libogg0 liborc-0_4-0 libpackagekit-glib2-18 libpango-1_0-0 libpciaccess0 libpixman-1-0 libpulse0 libsndfile1 libsoftokn3 libspeex1
libsqlite3-0 libstartup-notification-1-0 libtheoradec1 libtheoraenc1 libtiff5 libvisual libvorbis0 libvorbisenc2 libvorbisfile3 libwayland-client0 libwayland-cursor0 libwayland-server0
libX11-xcb1 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-render0 libxcb-shm0 libxcb-sync1 libxcb-util1 libxcb-xfixes0 libXcomposite1 libXcursor1 libXdamage1 libXevie1
libXfixes3 libXft2 libXi6 libXinerama1 libxkbcommon-0_4_3 libXrandr2 libXrender1 libxshmfence1 libXtst6 libXv1 libXxf86vm1 Mesa Mesa-libEGL1 Mesa-libGL1 Mesa-libglapi0
metatheme-adwaita-common MozillaFirefox MozillaFirefox-branding-openSUSE mozilla-nss mozilla-nss-certs PackageKit-gstreamer-plugin pango-tools sound-theme-freedesktop
The following 10 recommended packages were automatically selected:
gstreamer-fluendo-mp3 gtk2-branding-openSUSE gtk2-data gtk2-immodule-amharic gtk2-immodule-inuktitut gtk2-immodule-thai gtk2-immodule-vietnamese libcanberra0 libpulse0
PackageKit-gstreamer-plugin
128 new packages to install.
Overall download size: 77.2 MiB. Already cached: 0 B After the operation, additional 200.0 MiB will be used.
Continue? [y/n/? shows all options] (y): y
Retrieving package cantarell-fonts-0.0.16-1.1.noarch (1/128), 74.1 KiB (115.6 KiB unpacked)
Retrieving: cantarell-fonts-0.0.16-1.1.noarch.rpm .........................................................................................................................[done (63.4 KiB/s)]
Retrieving package hicolor-icon-theme-0.13-2.1.2.noarch (2/128), 40.1 KiB ( 50.5 KiB unpacked)
Retrieving: hicolor-icon-theme-0.13-2.1.2.noarch.rpm ...................................................................................................................................[done]
Retrieving package sound-theme-freedesktop-0.8-7.1.2.noarch (3/128), 372.6 KiB (460.3 KiB unpacked)
# zypper in 'gcc