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
總結
以上是生活随笔為你收集整理的linux 安装 powershell的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ASP.NET Core 中使用IHtt
- 下一篇: 精彩回放 | 玩转 VS Code 物联