chocolatey 安装_如何用Chocolatey将Linux风格的apt-get安装带到Windows

chocolatey 安装

chocolatey 安装

Linux users love installing software from the command line, and it’s not hard to understand why. Instead of downloading executables, running them, and dodging the various attempts to change your default search engine, you basically type what you want to install and hit “Enter.”

Linux用户喜欢从命令行安装软件,这并不难理解为什么。 基本上无需键入可执行文件,运行它们并躲避更改默认搜索引擎的各种尝试,而是键入要安装的内容并按“ Enter”。

If you want this kind of peace on Windows, look no further than Chocolatey, the package manager for Windows. This free tool lets you install thousands of apps with just a quick command (choco install), and update them all with another (choco upgrade.) This can save you a lot of time if you’re the kind of person who installs a lot of free software.

如果您想在Windows上实现这种平静,那么Windows的软件包管理器Chocolatey就是您的最佳选择。 这个免费的工具可让您仅用一个快速命令即可安装数千个应用程序 ( choco install ),并通过另一个命令进行更新( choco upgrade 。如果您是那种需要大量安装的人,则可以节省大量时间免费软件。

You can use Chocolatey in two places: the Command Prompt and PowerShell. Here’s how to install this package manager in both environments, but you only really need one or other other. Pick whatever you’re comfortable with.

您可以在两个地方使用Chocolatey:命令提示符和PowerShell。 这是在两种环境中安装此程序包管理器的方法,但是您只需要一个或另一个即可。 选择任何您喜欢的东西。

在命令提示符下安装和使用Chocolatey (Install and Use Chocolatey From the Command Prompt)

Chocolatey only works in the Command Prompt if you run it as administrator. The easiest way to do this is to right-click the Command Prompt in the Start Menu, and then click “Run as Administrator.”

Chocolatey仅在以管理员身份运行时才在命令提示符中起作用。 最简单的方法是右键单击“开始”菜单中的“命令提示符”,然后单击“以管理员身份运行”。

To install Chocolatey, first you need to run the following command, which downloads and runs the installer for you:

要安装Chocolatey,首先需要运行以下命令,该命令将为您下载并运行安装程序:

@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"

This command could change, so check the official Chocolatey instructions if you’re having trouble.

该命令可能会更改,因此如果遇到问题,请查阅官方Chocolatey说明

After you install Chocolatey, you can use it immediately (though in some cases you might need to close and re-open the admin Command Prompt). Installing software is simple: simply type choco install followed by the name of the program. Here, we’re running choco install filezilla to install the popular Filezilla FTP client.

安装Chocolatey之后,您可以立即使用它(尽管在某些情况下,您可能需要关闭并重新打开admin命令提示符)。 安装软件很简单:只需键入choco install然后输入程序名称即可。 在这里,我们正在运行choco install filezilla来安装流行的Filezilla FTP客户端。

You also don’t have to limit yourself to installing one app at a time. For example, using the following command will install all the listed apps in one go:

您也不必局限于一次安装一个应用程序。 例如,使用以下命令可以一次性安装所有列出的应用程序:

choco install firefox thunderbird vlc libreoffice

Of course you’ll need some way of knowing which packages exist and how they’re named. You can search to see if a given app is offered by using the following syntax:

当然,您将需要某种方式来知道存在哪些软件包以及如何命名它们。 您可以使用以下语法搜索以查看是否提供了给定的应用程序:

choco search key_word

In the following screenshot, for example, we’re using choco search thunderbird to search for packages related to the Thunderbird email client.

例如,在以下屏幕截图中,我们使用choco search thunderbird来搜索与Thunderbird电子邮件客户端相关的软件包。

Alternatively, this website offers a complete list of all packages you can install, complete with its own search tool.

另外, 该网站提供了您可以安装的所有软件包的完整列表,并带有自己的搜索工具。

If you want to upgrade a specific package to the latest version, use the command choco upgrade, followed by the package name. If you want to upgrade everything you’ve installed using Chocolatey in one go, choco upgrade all will do the trick. And there are more sub commands if you feel like digging. Just type choco -? to see a complete list.

如果要将特定软件包升级到最新版本,请使用choco upgrade,命令choco upgrade,后跟软件包名称。 如果您想一次升级使用Chocolatey安装的choco upgrade allchoco upgrade all就能解决问题。 如果您想挖掘的话,还有更多子命令。 只需输入choco -? 查看完整列表。

在PowerShell中安装和使用Chocolatey (Install and Use Chocolatey in PowerShell)

If you’re a big fan of PowerShell, you can use Chocolately from there as well. This means you can automate all kinds of things, once you get started with PowerShell and learn the ropes.

如果您是PowerShell的忠实拥护者,那么也可以从那里使用Chocolately。 这意味着,一旦您开始使用PowerShell并学习了绳索,就可以使各种事情自动化。

You’ll need to open an administrator PowerShell to get started. The simplest way to do that is to right-click the Start button, and then click “Windows PowerShell (Admin).”

您需要打开管理员PowerShell才能上手。 最简单的方法是右键单击“开始”按钮,然后单击“ Windows PowerShell(Admin)”。

Chocolatey, by its nature, requires permission to run scripts from outside your computer. For this reason, the official installation instructions recommend you change the ExecutionPolicy before installing Chocolatey. First, at the PowerShell prompt, type the following command and hit Enter:

从本质上讲,Chocolatey需要获得许可才能从计算机外部运行脚本。 因此, 官方安装说明建议您在安装Chocolatey之前更改ExecutionPolicy。 首先,在PowerShell提示符下,键入以下命令,然后按Enter:

Get-ExecutionPolicy

If you see a “Restricted” result, then you need to run the following command to set your execution policy so that the Chocolatey installation will work:

如果看到“受限”结果,则需要运行以下命令来设置执行策略,以便Chocolatey安装可以正常工作:

Set-ExecutionPolicy AllSigned

The command Set-ExecutionPolicy Bypass could also work, though this is the less secure option: it allows any script to run, regardless of whether its signed by the developer.

尽管此选项安全性较低,但命令Set-ExecutionPolicy Bypass也可以工作:它允许任何脚本运行,无论其是否由开发人员签名。

After setting the execution policy, you can run the installer using the following command:

设置执行策略后,可以使用以下命令运行安装程序:

iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

Just like that Chocolatey is installed! Using Chocolatey in Powershell is much the same as in the Command Prompt. Here’s choco install firefox running:

就像已安装Chocolatey! 在Powershell中使用Chocolatey与在命令提示符中使用相同。 这是运行choco install firefox

Subcommands like search and upgrade also work just like in the Command Prompt, and choco -? will give you a list of other functions. Have fun!

诸如searchupgrade类的子命令也可以像在命令提示符中那样工作, choco -? 将为您提供其他功能列表。 玩得开心!

翻译自: https://www.howtogeek.com/141783/how-to-bring-linux-style-apt-get-installations-to-windows-with-chocolatey/

chocolatey 安装

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值