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。
# 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 <alias|#|URI> Select packages from the specified repository. -r, --repo <alias|#|URI> 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 isto treat file conflicts as an error. --download-as-needed disables the fileconflict check. ......
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:
使用 ‘zypper refresh’ or ‘zypper ref’ 来刷新 zypper 软件库。
1
# zypper refresh
或者
1 2 3 4 5 6 7 8
# zypper ref Repository 'openSUSE-13.2-0'is up todate. Repository 'openSUSE-13.2-Debug'is up todate. Repository 'openSUSE-13.2-Non-Oss'is up todate. Repository 'openSUSE-13.2-Oss'is up todate. Repository 'openSUSE-13.2-Update'is up todate. Repository 'openSUSE-13.2-Update-Non-Oss'is up todate. All repositories have been refreshed.
刷新一个指定的软件库(以 ‘repo-non-oss’ 为例 )。
1 2 3
# zypper refresh repo-non-oss Repository 'openSUSE-13.2-Non-Oss'is up todate. Specified repositories have been refreshed.
强制更新一个软件库(以 ‘repo-non-oss’ 为例 )。
1 2 3 4 5 6
# 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 mr -rk -p85 repo-non-oss Repository 'repo-non-oss' priority has been left unchanged (85) Nothing tochangefor repository 'repo-non-oss'.
对所有的软件库关闭 rpm 文件缓存。
1 2 3 4 5 6 7 8 9 10
# 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'.
对所有的软件库开启 rpm 文件缓存。
1 2 3 4 5 6 7 8 9 10
# 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'.
关闭远程库的 rpm 文件缓存
1 2 3 4 5 6 7 8 9
# 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'.
开启远程软件库的 rpm 文件缓存。
1 2 3 4 5 6 7 8 9
# 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'.
The following 13 NEW packages are going to be installed: cpp cpp48 gcc gcc48 libasan0 libatomic1-gcc49 libcloog-isl4 libgomp1-gcc49 libisl10 libitm1-gcc49 libmpc3 libmpfr4 libtsan0-gcc49
13 new packages to install. Overall download size: 14.5 MiB. Already cached: 0 B After the operation, additional 49.4 MiB will be used. Continue? [y/n/? shows alloptions] (y): y
The following 13 NEW packages are going to be installed: cpp cpp48 gcc gcc48 libasan0 libatomic1-gcc49 libcloog-isl4 libgomp1-gcc49 libisl10 libitm1-gcc49 libmpc3 libmpfr4 libtsan0-gcc49
13 new packages to install. Overall download size: 14.5 MiB. Already cached: 0 B After the operation, additional 49.4 MiB will be used. Continue? [y/n/? shows all options] (y): y Retrieving package libasan0-4.8.3+r212056-2.2.4.x86_64 (1/13), 74.2 KiB (166.9 KiB unpacked) Retrieving: libasan0-4.8.3+r212056-2.2.4.x86_64.rpm .......................................................................................................................[done (79.2 KiB/s)] Retrieving package libatomic1-gcc49-4.9.0+r211729-2.1.7.x86_64 (2/13), 14.3 KiB ( 26.1 KiB unpacked) Retrieving: libatomic1-gcc49-4.9.0+r211729-2.1.7.x86_64.rpm ...............................................................................................................[done (55.3 KiB/s)]
The following 13 NEW packages are going to be installed: cpp cpp48 gcc gcc48 libasan0 libatomic1-gcc49 libcloog-isl4 libgomp1-gcc49 libisl10 libitm1-gcc49 libmpc3 libmpfr4 libtsan0-gcc49
13 new packages to install. Overall download size: 14.4 MiB. Already cached: 129.5 KiB After the operation, additional 49.4 MiB will be used. Continue? [y/n/? shows alloptions] (y): y In cache libasan0-4.8.3+r212056-2.2.4.x86_64.rpm (1/13), 74.2 KiB (166.9 KiB unpacked) In cache libatomic1-gcc49-4.9.0+r211729-2.1.7.x86_64.rpm (2/13), 14.3 KiB ( 26.1 KiB unpacked) In cache libgomp1-gcc49-4.9.0+r211729-2.1.7.x86_64.rpm (3/13), 41.1 KiB ( 90.7 KiB unpacked)
从指定的软件库里面安装一个软件包,例如从 amarok 中安装 libxine。
1 2 3 4 5 6 7 8 9
# zypper in amarok upd:libxine1 Loading repository data... Reading installed packages... Resolving package dependencies... The following 202 NEW packages are going to be installed: amarok bundle-lang-kde-en clamz cups-libs enscript fontconfig gdk-pixbuf-query-loaders ghostscript-fonts-std gptfdisk gstreamer gstreamer-plugins-base hicolor-icon-theme hicolor-icon-theme-branding-openSUSE htdig hunspell hunspell-tools icoutils ispell ispell-american kde4-filesystem kdebase4-runtime kdebase4-runtime-branding-openSUSE kdelibs4 kdelibs4-branding-openSUSE kdelibs4-core kdialog libakonadi4 l .....
The following 13 recommended packages were automatically selected: git-cvs git-email git-gui gitk git-svn git-web perl-Authen-SASL perl-Clone perl-MLDBM perl-Net-Daemon perl-Net-SMTP-SSL perl-PlRPC perl-SQL-Statement
The following package is suggested, but will not be installed: git-daemon
35new packages to install. Overall download size: 15.6 MiB. Already cached: 0 B After the operation, additional 56.7 MiB will be used. Continue? [y/n/? shows alloptions] (y): y
Problem: php5-5.6.1-18.1.x86_64 requires smtp_daemon, but this requirement cannot be provided uninstallable providers: exim-4.83-3.1.8.x86_64[openSUSE-13.2-0] postfix-2.11.0-5.2.2.x86_64[openSUSE-13.2-0] sendmail-8.14.9-2.2.2.x86_64[openSUSE-13.2-0] exim-4.83-3.1.8.i586[repo-oss] msmtp-mta-1.4.32-2.1.3.i586[repo-oss] postfix-2.11.0-5.2.2.i586[repo-oss] sendmail-8.14.9-2.2.2.i586[repo-oss] exim-4.83-3.1.8.x86_64[repo-oss] msmtp-mta-1.4.32-2.1.3.x86_64[repo-oss] postfix-2.11.0-5.2.2.x86_64[repo-oss] sendmail-8.14.9-2.2.2.x86_64[repo-oss] postfix-2.11.3-5.5.1.i586[repo-update] postfix-2.11.3-5.5.1.x86_64[repo-update] Solution 1: Following actions will be done: do not install php5-5.6.1-18.1.x86_64 do not install php5-pear-Auth_SASL-1.0.6-7.1.3.noarch do not install php5-pear-Horde_Http-2.0.1-6.1.3.noarch do not install php5-pear-Horde_Image-2.0.1-6.1.3.noarch do not install php5-pear-Horde_Kolab_Format-2.0.1-6.1.3.noarch do not install php5-pear-Horde_Ldap-2.0.1-6.1.3.noarch do not install php5-pear-Horde_Memcache-2.0.1-7.1.3.noarch do not install php5-pear-Horde_Mime-2.0.2-6.1.3.noarch do not install php5-pear-Horde_Oauth-2.0.0-6.1.3.noarch do not install php5-pear-Horde_Pdf-2.0.1-6.1.3.noarch ....
The following 29 NEW packages are going tobe installed: apache2 apache2-doc apache2-example-pages apache2-mod_perl apache2-prefork patterns-openSUSE-lamp_server perl-Data-Dump perl-Encode-Locale perl-File-Listing perl-HTML-Parser perl-HTML-Tagset perl-HTTP-Cookies perl-HTTP-Daemon perl-HTTP-Date perl-HTTP-Message perl-HTTP-Negotiate perl-IO-HTML perl-IO-Socket-SSL perl-libwww-perlperl-Linux-Pid perl-LWP-MediaTypes perl-LWP-Protocol-https perl-Net-HTTP perl-Net-SSLeay perl-Tie-IxHash perl-TimeDate perl-URI perl-WWW-RobotRules yast2-http-server
The following NEW pattern is going tobe installed: lamp_server
The following 10 recommended packages were automatically selected: apache2 apache2-doc apache2-example-pages apache2-mod_perl apache2-prefork perl-Data-Dump perl-IO-Socket-SSL perl-LWP-Protocol-https perl-TimeDate yast2-http-server
29new packages to install. Overall download size: 7.2 MiB. Already cached: 1.2 MiB After the operation, additional 34.7 MiB will be used. Continue? [y/n/? shows alloptions] (y):
使用一行命令安装一个软件包同时卸载另一个软件包,例如在安装 nano 的同时卸载 vi
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
# zypper in nano -vi Loading repository data... Reading installed packages... '-vi' not found in package names. Trying capabilities. Resolving package dependencies...
The following 2 NEW packages are going tobe installed: nano nano-lang
The following package is going tobe REMOVED: vim
The following recommended package was automatically selected: nano-lang
2new packages to install, 1toremove. Overall download size: 550.0 KiB. Already cached: 0 B After the operation, 463.3 KiB will be freed. Continue? [y/n/? shows alloptions] (y): ...
The following 24 NEW packages are going to be installed: alsa-oss-32bit fontconfig-32bit libasound2-32bit libexpat1-32bit libfreetype6-32bit libgcc_s1-gcc49-32bit libICE6-32bit libjpeg62-32bit libpng12-0-32bit libpng16-16-32bit libSM6-32bit libuuid1-32bit libX11-6-32bit libXau6-32bit libxcb1-32bit libXdamage1-32bit libXext6-32bit libXfixes3-32bit libXinerama1-32bit libXrandr2-32bit libXrender1-32bit libXtst6-32bit libz1-32bit teamviewer
The following recommended package was automatically selected: alsa-oss-32bit
24 new packages to install. Overall download size: 41.2 MiB. Already cached: 0 B After the operation, additional 119.7 MiB will be used. Continue? [y/n/? shows all options] (y): ..
The following 2 packages are going to be REMOVED: apache2 apache2-prefork
2 packages to remove. After the operation, 4.2 MiB will be freed. Continue? [y/n/? shows alloptions] (y): y (1/2) Removing apache2-2.4.10-19.1 ........................................................................[done] (2/2) Removing apache2-prefork-2.4.10-19.1 ................................................................[done]
使用Zypper 进行软件包更新
更新所有的软件包,可以使用 ‘zypper update‘ 或者 ‘zypper up‘。
1
# zypper up
或者
1 2 3 4 5
# zypper update
Loading repository data... Reading installed packages... Nothing to do.
更新指定的软件包,例如更新 apache2 以及 openssh。
1 2 3 4 5 6 7 8
zypper up apache2 openssh Loading repository data... Reading installed packages... No update candidate for'apache2-2.4.10-19.1.x86_64'. The highest available versionis already installed. No update candidate for'openssh-6.6p1-5.1.3.x86_64'. The highest available versionis already installed. Resolving package dependencies...
Nothing todo.
安装一个软件库,例如 mariadb,如果该库存在则更新之。
1 2 3 4 5 6 7 8
# zypper in mariadb Loading repository data... Reading installed packages... 'mariadb' is already installed. No update candidate for'mariadb-10.0.13-2.6.1.x86_64'. The highest available version is already installed. Resolving package dependencies...
The following 36 NEW packages are going tobe installed: autoconf automake bison cmake cpp cpp48 gcc gcc48 gcc48-c++ gcc-c++ libaio-devel libarchive13 libasan0 libatomic1-gcc49 libcloog-isl4 libedit-devel libevent-devel libgomp1-gcc49 libisl10 libitm1-gcc49 libltdl7 libmpc3 libmpfr4 libopenssl-devel libstdc++48-devel libtool libtsan0-gcc49 m4 make ncurses-devel pam-devel readline-devel site-config tack tcpd-devel zlib-devel
The following source package is going tobe installed: mariadb
36new packages to install, 1source package. Overall download size: 71.5 MiB. Already cached: 129.5 KiB After the operation, additional 183.9 MiB will be used. Continue? [y/n/? shows alloptions] (y): y
仅为某一个软件包安装源文件,例如 mariadb
1 2 3 4 5 6 7 8
# zypper in -D mariadb Loading repository data... Reading installed packages... 'mariadb' is already installed. No update candidate for'mariadb-10.0.13-2.6.1.x86_64'. The highest available version is already installed. Resolving package dependencies...
The following 36 NEW packages are going tobe installed: autoconf automake bison cmake cpp cpp48 gcc gcc48 gcc48-c++ gcc-c++ libaio-devel libarchive13 libasan0 libatomic1-gcc49 libcloog-isl4 libedit-devel libevent-devel libgomp1-gcc49 libisl10 libitm1-gcc49 libltdl7 libmpc3 libmpfr4 libopenssl-devel libstdc++48-devel libtool libtsan0-gcc49 m4 make ncurses-devel pam-devel readline-devel site-config tack tcpd-devel zlib-devel
The following package is recommended, but will not be installed due to conflicts or dependency issues: readline-doc
36new packages to install. Overall download size: 33.7 MiB. Already cached: 129.5 KiB After the operation, additional 144.3 MiB will be used. Continue? [y/n/? shows alloptions] (y): y
在脚本和应用中调用 Zypper (非交互式)
安装一个软件包,并且在安装过程中跳过与用户的交互, 例如 mariadb。
1 2 3 4 5 6 7 8
# zypper --non-interactive in mariadb Loading repository data... Reading installed packages... 'mariadb' is already installed. No update candidate for'mariadb-10.0.13-2.6.1.x86_64'. The highest available version is already installed. Resolving package dependencies...
The following packageis going to be REMOVED: mariadb
1packageto remove. After the operation, 71.8 MiB will be freed. Continue? [y/n/? shows all options] (y): y (1/1) Removing mariadb-10.0.13-2.6.1 .............................................................................[done]
# zypper --quiet in mariadb The following NEWpackageis going to be installed: mariadb
1newpackageto install. Overall download size: 0 B. Already cached: 7.8 MiB After the operation, additional 71.8 MiB will be used. Continue? [y/n/? shows all options] (y): ...
可以使用 Zypper 命令的 ‘dist-upgrade’ 选项来将当前的 SUSE Linux 升级至最新版本。
1 2 3 4 5 6 7
# zypper dist-upgrade You are about to do a distribution upgrade with all enabled repositories. Make sure these repositories are compatible before you continue. See 'man zypper'for more information about this command. Building repository 'openSUSE-13.2-0' cache .....................................................................[done] 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]