Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install PowerShell under Linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today, the editor will share with you the relevant knowledge about how to install PowerShell under Linux. The content is detailed and the logic is clear. I believe most people still know too much about this, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.

PowerShell is a cross-platform (Windows, Linux and OS X) automation and configuration tool (framework) that can be integrated amicably with existing tools, especially optimized for dealing with structured data (such as JSON, CSV, XML, etc.), REST APIs and object models. It contains a command line Shell, an associated scripting language, and a framework for processing cmdlets.

Install PowerShell Core 6.0in Linux system

To install PowerShell Core 6.0in Linux, we will use the Microsoft Software Repository, which allows us to install through the most popular Linux package manager tools such as apt-get, yum, etc.

Installed in Ubuntu 16.04

First, import the GPG key of the public repository, and then register the Microsoft Ubuntu repository with the source of APT to install PowerShell:

$curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add-$curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee / etc/apt/sources.list.d/microsoft.list$ sudo apt-get update$ sudo apt-get install-y powershell installs $curl https://packages.microsoft.com/keys/microsoft.asc in Ubuntu 14.04 | sudo apt-key add-$curl https://packages.microsoft.com / config/ubuntu/14.04/prod.list | sudo tee / etc/apt/sources.list.d/microsoft.list$ sudo apt-get update$ sudo apt-get install-y powershell is installed in CentOS 7

First, register the Microsoft RedHat repository with the YUM package manager warehouse list, and then install PowerShell:

$sudo curl https://packages.microsoft.com/config/rhel/7/prod.repo > / etc/yum.repos.d/microsoft.repo$ sudo yum install-y powershell how to use PowerShell Core 6.0in Linux

In this section, we will briefly introduce PowerShell;. We will see how to start PowerShell, run some basic commands, and manipulate files, directories, and processes. Then learn how to list all available commands, display command help, and aliases.

Enter the following command to start PowerShell:

$powershell

Start PowerShell in Linux

You can view the PowerShell version with the following command:

$PSVersionTable

View PowerShell version

Run the basic PowerShell command in Linux.

Get-date [# Show current date] get-uptime [# Show boot time] get-location [# Show current working directory] manipulate files and directories in PowerShell

1. You can create an empty file in two ways:

New-item tecmint.tex or "" > tecmint.tex

Then add content to it and view the contents of the file.

Set-content tecmint.tex-value "TecMint Linux How Tos Guides" get-content tecmint.tex

Create a new file in PowerShell

2. Delete a file in PowerShell

Remove-item tecmint.texget-content tecmint.tex

Delete a file in PowerShell

3. Create a directory

Mkdir tecmint-filescd tecmint-files "" > domains.listls

Create a directory in PowerShell

4. Perform the list operation in long format, listing the details of the file / directory, including the mode (file type), the last modification time, etc., using the following command:

Dir

List directory length in Powershell

5. Show all the processes in the system:

Get-process

Show running processes in PowerShell

6. View the details of the running process / process group with the given name, and pass the process name as a parameter to the above command, as follows:

Get-process apache2

View the specified process in PowerShell

The meaning of each part of the output:

NPM (K)-the non-paged memory used by the process, in Kb. PM (K)-the pageable memory used by the process, in Kb. WS (K)-the working set size of the process, in Kb, which consists of memory pages referenced by the process. CPU (s)-the processor time spent by the process on all processors, in seconds. ID-process ID (PID) .ProcessName-process name.

7. To learn more, get a list of PowerShell commands:

Get-command

List commands for PowerShell

8. If you want to know how to use a command, check its help (similar to man in Unix/Linux); for example, you can get help from the command Describe:

Get-help Describe

PowerShell help manual

9. Display the aliases of all commands and type:

Get-alias

List PowerShell command aliases

10. Last but not least, display the command history (a list of commands that have been run):

History

Show PowerShell command history

That's it! In this article, we show how to install Microsoft PowerShell Core 6. 0 in Linux. In my opinion, compared with the traditional Unix/Linux shell, PowerShell still has a long way to go. For now, it seems that PowerShell also needs to provide better, more exciting, and productive features in areas such as operating machines on the command line and, more importantly, programming (scripting).

These are all the contents of the article "how to install PowerShell under Linux". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report