In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to install and use PowerShell in Linux. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
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
Installed in Ubuntu 14.04
$curl https://packages.microsoft.com/keys/microsoft.asc | 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
Install 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:
$PSVersionTable
You can view the PowerShell version with the following command:
$powershell
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
2. Delete a file in PowerShell
Remove-item tecmint.texget-content tecmint.tex
3. Create a directory:
Mkdir tecmint-filescd tecmint-files "" > domains.listls
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
5. Show all the processes in the system:
Get-process
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
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
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
9. Display aliases for all commands and enter:
Get-alias
10. Last but not least, display the command history (a list of commands that have been run):
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).
This is the end of the article on "how to install and use PowerShell in Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.