Install PowerShell on AlmaLinux 9 and RHEL 9

This tutorial intends to teach you to Install PowerShell on AlmaLinux 9 and RHEL 9. PowerShell is a powerful tool with a command-line shell that is used to help IT professionals configure systems and automate administrative tasks.

How To Install PowerShell on AlmaLinux 9 and RHEL 9?

To complete this guide, you must have access to your server as a non-root user with sudo privileges. To do this, you can follow this guide on Initial Server Setup with AlmaLinux 9.

In this guide, we will show you to install PowerShell in different ways:

  • Via GitHub
  • With Snap Package manager

Now follow the steps below to complete this guide.

Step 1 – Run System Update on AlmaLinux 9 / RHEL 9

To use any methods to install PowerShell, you must update your local package index by using the command below:

sudo dnf update -y

Then, proceed to the next step to install your PowerShell.

Step 2 – PowerShell Installation Via GitHub on AlmaLinux 9 / RHEL 9

PowerShell is supported on most Linux distributions. You can find the latest PowerShell Linux packages on GitHub.

To install PowerShell, find the latest rpm package and use the command below to install it on your server:

sudo dnf install https://github.com/PowerShell/PowerShell/releases/download/v7.3.4/powershell-7.3.4-1.rh.x86_64.rpm

Verify your installation, by typing the following command in your Linux terminal:

pwsh

In your output, you should see:

Output
PowerShell 7.3.4
PS /root> 

To exit from your PowerShell, you can simply type exit:

PS /root> exit

Step 3 – PowerShell Installation with Snapd on AlmaLinux 9 / RHEL 9

Another way that you can install your PowerShell is to use the snap package manager. First, install the Epel repo on your server by using the command below:

sudo dnf install epel-release -y

Then, install snap packages on your server by using the following command:

sudo dnf install snapd -y

At this point, you must enable and start the Snapd service with the following commands:

# sudo systemctl enable --now snapd.socket
# sudo systemctl start --now snapd.socket

Next, enable the classic snap support by creating a symbolic link between /var/lib/snapd/snap and /snap:

sudo ln -s /var/lib/snapd/snap /snap

Then, restart your session with the command below:

reboot

When you logged back, use Snap to install your PowerShell on AlmaLinux 9:

sudo snap install powershell --classic
Output
powershell 7.3.4 from Microsoft PowerShell✓ installed

Verify your installation, by typing the following command in your Linux terminal:

pwsh
Output 
PowerShell 7.3.4 
PS /root>  

Step 4 – PowerShell Commands on Linux

To get commands from your PowerShell, you can easily type the command below:

PS /root> Get-Command

You will get a list of commands as shown below:

Output 
CommandType     Name                                               Version    S
                                                                              o
                                                                              u
                                                                              r
                                                                              c
                                                                              e
-----------     ----                                               -------    -
Function        cd..
Function        cd\
Function        Clear-Host
Function        Compress-Archive                                   1.2.5      M
Function        exec
Function        Expand-Archive                                     1.2.5      M
Function        Find-Command                                       2.2.5      P
Function        Find-DSCResource                                   2.2.5      P
Function        Find-Module                                        2.2.5      P
Function        Find-RoleCapability                                2.2.5      P
Function        Find-Script                                        2.2.5      P
Function        Get-CredsFromCredentialProvider                    2.2.5      P
Function        Get-InstalledModule                                2.2.5      P
Function        Get-InstalledScript                                2.2.5      P
Function        Get-PSRepository                                   2.2.5      P
Function        help
Function        Install-Module                                     2.2.5      P
Function        Install-Script                                     2.2.5      P
Function        New-ScriptFileInfo                                 2.2.5      P
Function        oss
Function        Pause
Function        prompt
....

For more information, you can visit PowerShell Docs.

Conclusion

At this point, you have learned to Install PowerShell in the Latest release From GitHub and with Snapd service on AlmaLinux 9 and RHEL 9. Enjoy using PowerShell on your Linux distro.

You may be interested in these articles on the Orcacore website:

How To Install Java with DNF on AlmaLinux 9

Set Up NFS Server and Client on AlmaLinux 9

How To Install GitHub Desktop on AlmaLinux 9

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

POPULAR TAGS

Most Popular