Chocolatey的安装与使用—Windows下的包管理工具 (terminal install sofeware)

前言

在 Linux 下,大家喜欢用 apt-get 来安装应用程序,如今在 windows 下,大家可以使用 Chocolatey 来快速下载搭建一个开发环境。

Chocolatey 的哲学就是完全用命令行来安装应用程序, 它更像一个包管理工具(背后使用 Nuget )

另外需要说明的是, Chocolatey 只是把官方下载路径封装到了 Chocolatey 中,所以下载源都是其官方路径,所以下载的一定是合法的,但是如果原软件是需要 Licence 注册的话,那么 Chocolatey 下载安装好的软件还是需要你去购买注册。不过 Chocolatey 一般还是会选用免费 Licence 可用的软件。

Chocolatey官网:https://chocolatey.org/

安装

用管理员打开cmd,执行以下命令:

Install with cmd.exe

Run the following command:

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

Install with PowerShell.exe

With PowerShell, there is an additional step. You must ensure Get-ExecutionPolicy is not Restricted. We suggest using Bypass to bypass the policy to get things installed or AllSigned for quite a bit more security.

  • Run Get-ExecutionPolicy. If it returns Restricted, then run Set-ExecutionPolicy AllSigned or Set-ExecutionPolicy Bypass.
  • Now run the following command:
    # Don't forget to ensure ExecutionPolicy above
    iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

Additional considerations

NOTE: Please inspect https://chocolatey.org/install.ps1 prior to running any of these scripts to ensure safety. We already know it’s safe, but you should also be comfortable before running any script from the internet you are not familiar with. All of these scripts download a remote PowerShell script and execute it on your machine.

执行完毕之后,chocolatey就安装好了。

安装包

安装包十分的容易,只需要打开管理员权限的命令行即可:

choco install <package>

卸载包

卸载也同样十分简单,打开管理员权限命令行,执行:

choco uninstall <package>

更新包

更新包则需要使用如下命令:

choco upgrade <package>

安装软件 (参考/搜索:https://chocolatey.org/packages

安装软命令

choco install ruby
cinst ruby

安装ruby

choco install ruby

安装 Python

choco install python

安装 Java JDK7 或 JDK8

choco install jdk7
choco install jdk8

安装编辑器 notepad++/atom/sublime (另外还有各种IDE,不列出了)

choco install notepadplusplus.install
choco install Atom
choco install SublimeText3

搜索软件

clist ssh
choco list ssh

卸载软件

clist ssh
cuninst ssh

其它

我的chocolatey安装目录为:

C:\Users\chzhao\AppData\Local\Temp\chocolatey\chocInstall\tools\chocolateyInstall

其它命令还包括:

cpack
cpush
cup
cver

更多参考: Mac下Homebrew的安装与使用 – brew

 

本文:Chocolatey的安装与使用—Windows下的包管理工具

 

Loading

One Comment

Add a Comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.