SUSE Linux-Zypper command example
Zypper is a command line interface used in SUSE Linux to install, upgrade, uninstall, manage repositories, and query various packages. This article will discuss several examples of different commands of zypper.
Syntax:
- # Zypper [-- global-opts] <command> [-- command-opts] [command-arguments]
The section in the brackets can be unnecessary. The simplest way to execute zypper is to input zypper and.
Example 1: List available Global Options and commands
Open the terminal, enter zypper, and press enter to display all available Global Options and commands.
- Linux-xa3t :~ # Zypper
Example 2: get help from a command of zypper
Syntax: zypper help [command]
- Linux-xa3t :~ # Zypper help remove
- Remove (rm) [options] <capability>...
-
- Remove packages with specified capabilities.
- A capability is NAME [. ARCH] [OP <VERSION>], where OP is one of <, <=, =, >=,>.
-
- Command options:
- -R, -- repo <alias | # | URI> Load only the specified repository.
- -T, -- type <type> Type of package (package, patch, pattern, product ).
-
- Default: package.
- -N, -- name Select packages by plain name, notby capability.
- -C, -- capability Select packages by capability.
- -- Debug-solver Create solver test casefor debugging.
- -R, -- no-force-resolution Donot force the solver to find solution, let it ask.
- -- Force-resolution Force the solver to find a solution (even an aggressive one ).
- -U, -- clean-deps Automatically remove unneeded dependencies.
- -U, -- no-clean-deps No automatic removal of unneeded dependencies.
- -D, -- dry-run Test the removal, donot actually remove.
Example 3: Open zypper shell/session
- Linux-xa3t :~ # Zypper sh
- Zypper>
Or
- Linux-xa3t :~ # Zypper shell
- Zypper>
Example 4: List the defined Repositories
- Linux-xa3t :~ # Zypper repos
Or
- Linux-xa3t :~ # Zypper lr
4.1) List warehouse URIs in a table
4.2) List warehouses with priority
- Linux-xa3t :~ # Zypper lr-p
Example 5: refresh the Repository
- Linux-xa3t :~ # Zypper ref
- Repository 'opensuse-13.1-Non-Oss' is up to date.
- Repository 'opensuse-13.1-Oss' is up to date.
- Repository 'opensuse-13.1-Update' is up to date.
- Repository 'opensuse-13.1-Update-Non-Oss' is up to date.
- All repositories have been refreshed.
Example 6: Modify the zypper Repository
The zypper repository can be modified using aliases, numbers, or Uris, or '-all,-remote,-local, and-medium-type.
Linux-xa3t :~ # Zypper mr-d 6 # disable warehouse linux-xa3t No. 6 :~ # Zypper mr-rk-p 70 upd # Enable Automatic correspondence and set rpm file 'cache' for the 'upd' warehouse, and set it to priority 70 linux-xa3t :~ # Zypper mr-Ka # disable rpm File Cache linux-xa3t for all repositories :~ # Zypper mr-kt # Set the rpm file cache for the remote Repository
Example 7: Add a repository
Syntax: zypper addrepo or zypper ar <repository URL or alias>
- Linux-xa3t :~ # Zypper ar http://download.opensuse.org/update/13.1/ update
- Adding repository 'update '................................... .......... [done]
- Repository 'update' successfully added
- Enabled: Yes
- Autorefresh: No
- GPG check: Yes
- URI: http://download.opensuse.org/update/13.1/
Example 8: Remove a repository
Syntax: zypper removerepo <repository Name> <alias>
Or
Zypper rr <repository Name> <alias>
- Linux-xa3t :~ # Zypper rr openSUSE-13.1-1.10 openSUSE-13.1-1.10
- Removing repository 'opensuse-13.1-1.10 '...... [done]
- Repository 'opensuse-13.1-1.10 'has been removed.
For more details, please continue to read the highlights on the next page: