0725_Linux安装PowershellCore

240 阅读1分钟

Powershell 原来是 Window 上面的 Shell。本来是不能在 Linux 上使用的,但是 .Net Core 的出现, Powershell 能够进行跨平台了。

在 Powershell 中,是有数据类型的,可以说一切皆对象,而不是类似其他的 Bash Shell 那样,只有字符类型这一种。甚至 Powershell 还能够借助 .net 类库的力量,更方便的完成自己的需求。

# 从 Github 下载归档包,重命名为 powershell.tar.gz

curl -L https://github.com/PowerShell/PowerShell/releases/download/v6.1.3/powershell-6.1.3-linux-x64.tar.gz -o /tmp/powershell.tar.gz

# 提前在 创建目录,存放文件
sudo mkdir -p /opt/microsoft/powershell

# 解压文件
sudo tar -xzf /tmp/powershell.tar.gz -C /opt/microsoft/powershell/

# 建立软链接
sudo ln -s /opt/microsoft/powershell/pwsh /usr/bin/pwsh

# 赋予运行权限
sudo chmod a+x /usr/bin/pwsh

# 在 bash shell 上面输入 pwsh 即可使用

# 使用 exit 命令, 退出 powershell 命令行环境