How to use the command 'rankmirrors' (with examples)

How to use the command 'rankmirrors' (with examples)

The command ‘rankmirrors’ is a utility in Arch Linux used to rank a list of Pacman mirrors based on connection and opening speed. It is commonly used to generate an optimized mirrorlist file, which is then used by Pacman to download packages efficiently. The command provides several options to customize the ranking process and output format.

Use case 1: Rank a mirror list

Code:

rankmirrors /etc/pacman.d/mirrorlist

Motivation: Ranking a mirror list helps to identify and select the fastest mirrors available, ensuring faster package downloads and updates in Arch Linux. By running this command, users can obtain a ranked mirrorlist file in which the mirrors are sorted based on their connection and opening speeds.

Explanation:

  • /etc/pacman.d/mirrorlist: This argument specifies the path to the mirrorlist file that will be ranked.

Example Output:

## Arch Linux mirrorlist generated by rankmirrors v3
## URL: https://wiki.archlinux.org/mirrorlist

Server = https://mirror.netcologne.de/archlinux/$repo/os/$arch
Server = https://arch.mirror.constant.com/$repo/os/$arch
Server = https://archlinux.mailtunnel.eu/$repo/os/$arch
Server = https://ftp.lysator.liu.se/pub/archlinux/$repo/os/$arch
Server = https://mirror.dkm.cz/archlinux/$repo/os/$arch
...

Use case 2: Output only a given number of the top ranking servers

Code:

rankmirrors -n <number> /etc/pacman.d/mirrorlist

Motivation: Sometimes users may only be interested in the top-ranked mirrors, especially if they want to limit the number of mirrors used for their Pacman operations. This option allows users to specify the number of top-ranking servers they want the command to output.

Explanation:

  • -n: This option is used to limit the number of top-ranked servers displayed.
  • <number>: This argument specifies the desired number of top-ranked servers to be shown.

Example Output:

Server = https://mirror.netcologne.de/archlinux/$repo/os/$arch
Server = https://arch.mirror.constant.com/$repo/os/$arch
Server = https://archlinux.mailtunnel.eu/$repo/os/$arch

Use case 3: Be verbose when generating the mirrorlist

Code:

rankmirrors -v /etc/pacman.d/mirrorlist

Motivation: Sometimes users may want to see detailed information about the ranking process to understand how the mirrorlist is generated. By using this option, the command will provide verbose output, giving users insight into the connection testing and ranking procedures.

Explanation:

  • -v: This option enables verbose output, providing detailed information during the mirrorlist generation process.

Example Output:

Testing mirror: https://mirror.netcologne.de/archlinux/$repo/os/$arch
Testing connection speed...
Connected to https://mirror.netcologne.de/archlinux/$repo/os/$arch (IP: 195.135.221.134) with a response time of 32 ms
...

Use case 4: Test only a specific URL

Code:

rankmirrors --url <url>

Motivation: In some cases, users may want to check the connection and opening speed of a specific mirror URL without ranking the entire mirrorlist. This option allows users to test a specific mirror URL and obtain its connection and opening speed.

Explanation:

  • --url: This option is used to specify the URL that will be tested.

Example Output:

Testing mirror: https://mirror.netcologne.de/archlinux/$repo/os/$arch
Testing connection speed...
Connected to https://mirror.netcologne.de/archlinux/$repo/os/$arch (IP: 195.135.221.134) with a response time of 32 ms

Use case 5: Output only the response times instead of a full mirrorlist

Code:

rankmirrors --times /etc/pacman.d/mirrorlist

Motivation: Sometimes users may only want to obtain the response times for each mirror without the full mirrorlist. This can be useful for comparing the performance of different mirrors based on their response times alone.

Explanation:

  • --times: This option instructs the command to output only the response times of the mirrors instead of a full mirrorlist.

Example Output:

32
27
41
...

Conclusion:

The command ‘rankmirrors’ is a valuable tool for managing Pacman mirrors in Arch Linux. It allows users to rank mirrors based on their connection and opening speeds, enabling them to optimize their package downloads. With the various options available, users have the flexibility to customize the output format and select only the desired information.

Related Posts

How to use the command "kosmorro" (with examples)

How to use the command "kosmorro" (with examples)

“kosmorro” is a command-line tool that allows users to compute the ephemerides and events for a given date at a specified position on Earth.

Read More
How to use the command pmount (with examples)

How to use the command pmount (with examples)

pMount is a command-line utility that allows users to mount arbitrary hotpluggable devices as a normal user.

Read More
How to use the command 'git psykorebase' (with examples)

How to use the command 'git psykorebase' (with examples)

Git psykorebase is a command that allows users to rebase a branch on top of another using a merge commit with only one conflict handling.

Read More