Learn how to – How To Install PowerShell on RHEL / CentOS 8/7.
PowerShell is a scripting language originally written for Windows systems by Microsoft, but support for Linux/Unix systems has been made a reality. If you’re a Windows developer or Systems Administrator coming from Windows background, you’re definitely using PowerShell.
PowerShell is a powerful object-oriented scripting language, with support for objects, classes, and methods, much like any OOP language. These features are not available on the traditional Linux shell. This guide will help you install PowerShell on your Red Hat Enterprise Linux / CentOS 7/8 machine.
Also check: Best Terminal emulators for Linux
Step 1: Add PowerShell repository
The PowerShell Core RPM package is not available on your default CentOS / RHEL repositories. We’ll add official Microsoft repositories using the command.
curl https://packages.microsoft.com/config/rhel/7/prod.repo | sudo tee /etc/yum.repos.d/microsoft.repo
We’re now rolling to install PowerShell Core.
Step 2: Install PowerShell on RHEL / CentOS 8/7
We proceed to install PowerShell on RHEL / CentOS 8/7 system. This command is run on the terminal to perform the action.
sudo yum install -y powershell
The rpm command reveals more information about installed PowerShell package.
$ rpm -qi powershell
Name : powershell
Version : 6.2.0
Release : 1.rhel.7
Architecture: x86_64
Install Date: Sun 28 Apr 2019 03:18:56 AM EAT
Group : shells
Size : 157846730
License : MIT License
Signature : RSA/SHA256, Mon 25 Mar 2019 10:53:15 PM EAT, Key ID eb3e94adbe1229cf
Source RPM : powershell-6.2.0-1.rhel.7.src.rpm
Build Date : Mon 25 Mar 2019 08:43:28 PM EAT
Build Host : 01a688a797cd
Relocations : /
Packager : PowerShell Team <PowerShellTeam@hotmail.com>
Vendor : Microsoft Corporation
URL : https://microsoft.com/powershell
Summary : PowerShell is an automation and configuration management platform.
Description :
PowerShell is an automation and configuration management platform.
It consists of a cross-platform command-line shell and associated scripting language.
Step 3: Start and Use PowerShell on RHEL / CentOS 8/7
After the installation, start PowerShell using the command:
$ pwsh
PowerShell 6.2.0
Copyright (c) Microsoft Corporation. All rights reserved.
https://aka.ms/pscore6-docs
Type 'help' to get help.
PS /root>
Let’s run a few commands to confirm our PowerShell is working on RHEL/CentOS server.
PS /root> pwd
Path
----
/root
PS /root> mkdir /tmp/test
PS /root> cd /tmp/test
PS /tmp/test> pwd
Path
----
/tmp/test
PS /tmp/test> get-process | more
NPM(K) PM(M) WS(M) CPU(s) Id SI ProcessName
------ ----- ----- ------ -- -- -----------
0 0.00 0.86 0.02 3482 …82 agetty
0 0.00 0.85 0.02 3483 …83 agetty
0 0.00 2.00 69.49 15645 …26 apps.plugin
0 0.00 0.00 0.02 652 0 ata_sff
0 0.00 0.92 0.02 3481 …81 atd
0 0.00 0.88 1.36 1625 …25 auditd
0 0.00 1.51 0.94 15884 …26 bash
0 0.00 3.01 0.07 15931 …31 bash
0 0.00 0.00 0.00 23 0 bioset
0 0.00 0.00 0.00 24 0 bioset
0 0.00 0.00 0.00 25 0 bioset
0 0.00 2.04 2.92 2138 …30 chronyd
0 0.00 1.64 7.00 3479 …79 crond
0 0.00 0.00 0.00 42 0 crypto
0 0.00 2.40 25.34 2110 …10 dbus-daemon
0 0.00 0.00 0.00 67 0 deferwq
0 0.00 2.66 0.06 3208 …08 dhclient
0 0.00 0.00 0.00 28 0 edac-poller
0 0.00 0.00 0.00 1323 0 ext4-rsv-conver
0 0.00 28.22 0.77 2418 …18 firewalld
0 0.00 9.42 533.72 3673 …26 go.d.plugin
0 0.00 0.00 0.00 54 0 ipv6_addrconf
0 0.00 1.20 210.99 2101 …01 irqbalance
0 0.00 0.00 9.31 1317 0 jbd2/sda1-8
.....................................................................
That is enough to substantiate our PowerShell functioning on RHEL / CentOS 7/8 system.
Leave a Reply
You must be logged in to post a comment.