bash: ls
PS: Get-ChildItem(dir,ls)
ls
Bash: cd
PS : Set-Location(cd)
cd C:\Windows
Bash: pwd
PS: Get-Location(pwd)
Bash: mkdir
PS: New-Item xxx -ItemType Directory
New-Item -Path C:\Temp\NewFolder -ItemType Directory
Bash:rm
PS: Remove-Item(rm,del)
rm C:\Temp\file.txt
Bash:cp
PS:Copy-Item(cp)
cp C:\Temp\file.txt C:\Temp\Backup\file.txt
Bash: mv
PS: Move-Item(mv)
mv C:\Temp\file.txt C:\Temp\Backup\file.txt
Bash:touch
PS:New-Item
New-Item -Path C:\Temp\file.txt -ItemType File
Bash: cat
PS: Get-Content(cat,type)
cat C:\Temp\file.txt
Bash: echo
PS:Write-Output(echo)
echo "Hello, World!"
Bash:>,>>
PS: Out-File, Add-Content
Out-File C:\Temp\file.txt`
Bash:ps
PS:Get-Process
Get-Process
Bash: kill
PS: Stop-Process
Stop-Process -Name notepad
Bash: top
PS:Get-Process | Sort-Object CPU -Descending
`Get-Process
Bash:uname -a
PS: Get-ComputerInfo
Get-ComputerInfo
Bash: df
PS: Get-PSDDrive
Get-PSDrive
Bash: free
PS: Get-Counter
Get-Counter
Bash: ping
PS: Test-Connection(ps)
Test-Connection www.baidu.com
Bash: ifconfig
PS: Get-NetIPAddress
Get-NetIPAddress
Bash: netstat
PS: Get-NetTCPConnection
Get-NetTCPConnection
Bash: curl
curl: Invoke-WebRequest(curl,wget)
curl
Bash: whoami
PS: Get-WmiObject
Get-WmiObject
Bash:sudo
PS:Start-Process -Verb RunAs
Start-Process powershell -Verb RunAs
Bash: passwd
PS: Set-LocalUser
Set-LocalUser -Name "User" -Password (ConvertTo-SecureString "NewPassword" -AsPlainText -Force)
Bash: grep
PS: Select-String
Select-String "keyword"`
Bash: awk
PS: ForEach-Object
ForEach-Object { $_.Split()[0] }`
Bash: sed
PS: -replace
Get-Content C:\Temp\file.txt) -replace "old", "new"
Bash: wc
PS: Measure-Object
Measure-Object -Line -Word`
Bash: apt-get
PS: Install-Package
Install-Package -Name Notepad++
Bash: yum
PS: Find-Package
find-package -Name Chrome
Bash: man
PS: Get-Help
Get-help Get-Process
Bash: history
PS: Get-History
Get-History
Bash: clear
PS: Clear-Host
Clear-Host
Bash: exit
PS: Exit
Exit
【总结】
PowerShell和Linux的命令在功能上有相似之处,但语法和用法有所不同。PowerShell更注重对象操作,而Linux命令通常以文本为中心。