linux 安装_linux 安装 powershell

linux 安装 powershell

Intro

powershell 已经推出了一个 Powershell Core, 版本号对应 Powershell 6.x,可以跨平台,支持 Linux 和 mac. 这使得对于熟练使用 Powershell 进行开发运维的一些开发者来说无疑是个福音。

PowerShell 和 PowerShell Core

那Windows PowerShell与PowerShell Core 6.0又有什么区别呢,主要几个区别如下:

  • Windows PowerShell是基于.NET Framework的,所以它也只能在Windows中使用。 PowerShell Core 6.0发布时,Windows PowerShell 最新的版本在5.*,但PowerShell Core 6.0 可不是Windows PowerShell的升级版本。

  • PowerShell Core 6.0因为它的跨平台,自然不仅可以在 Windows 上运行也可以在其它平台如macOS与Linux上运行,因为它是基于.NET Core基础之上的。

  • Windows PowerShell在 Windows 中的执行文件为powershell.exe,而PowerShell Core 6.0在Windows中的执行文件是pwsh.exe,在 macOS 和 Linux 中的执行文件是 pwsh

PowerShell Core 平台支持情况

PowerShell 现在官方支持 macOS 和 Linux,包括:

  • Windows 7、8.1 和 10

  • Windows Server 2008 R2、2012 R2、2016

  • Windows Server 半年频道

  • Ubuntu 14.04、16.04 和 17.04

  • Debian 8.7+ 和 9

  • CentOS 7

  • Red Hat Enterprise Linux 7

  • OpenSUSE 42.2

  • Fedora 25、26

  • macOS 10.12+

我们社区也为以下平台提供包,但是它们不受正式支持:

  • Arch Linux

  • Kali Linux

  • AppImage(可在多个 Linux 平台上运行)

我们还对以下平台提供试验版本(不受支持):

  • ARM32/ARM64 上的 Windows

  • Raspbian (Stretch)

在 Linux上安装 PowerShell

这里以 Centos 为例,介绍如何安装 PowerShell,其他 Linux 系统可以参考这里的文档

这里有两种方式可以安装

  • 注册微软的镜像源(推荐)

# Register the Microsoft RedHat repository

curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo

# Install PowerShell

sudo yum install -y powershell

  • 直接下载文件安装

sudo yum install https://github.com/PowerShell/PowerShell/releases/download/v6.1.0/powershell-6.1.0-1.rhel.7.x86_64.rpm

安装完成之后可以直接执行 pwsh 就可以进入 powershell 了,如果可以正常进入则证明安装成功了。

卸载

sudo yum remove powershell

Reference

  • https://docs.microsoft.com/zh-cn/powershell/scripting/whats-new/what-s-new-in-powershell-core-60?view=powershell-6

  • https://docs.microsoft.com/zh-cn/powershell/scripting/setup/installing-powershell-core-on-linux?view=powershell-6#centos-7

Contact

Contact me: weihanli@outlook.com

f5f512e6cf00bb6ee279512d8b6e8a48.png

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值