Freigeben über


CentOS 7에 Powershell 설치하기

안녕하세요.

오늘 포스팅할 내용은 CentOS 7에 Powershell(이하 파워쉘)을 설치하여 사용하는 방법입니다.

Microsoft가 개발한 스크립트 언어를 특징으로 하는 명령어 인터프리터인 파우쉘이 Linux에서 설치하여 사용할 수 있다니 솔직히 무척 놀랍고도 반가운 내용입니다. 윈도우에서만큼 잘 동작하고 많은 기능들을 사용할 수 있기를 기대해봅니다.

오늘 포스팅은 다음 순서로 이루어져있습니다.

1. CentOS 7 파워쉘 다운로드 및 설치

2. 파워쉘 명령어 실행하여 사용하기

 

 

 

 

 

1. CentOS 7 파워쉘 다운로드 및 설치

CentOS 7에 파우쉘을 설치하기 위해서는 먼저 파워쉘을 다운로드 받아야 합니다.

다운로드: https://github.com/PowerShell/PowerShell/releases/

CentOS에 파워쉘이 설치되어있는지 확인합니다.

명령어: rpm -qa | grep powershell

CentOS 7에서 다운로드 받은 파일이 있는 공유 폴더를 마운트하여 설치를 준비합니다.

명령어: : Mount -t cifs -o username=계정명 //윈도우 공유 폴더 경로 /마운트할 폴더명

마운트한 폴더로 이동하여 설치할 파일이 존재하는지 확인합니다.

CentOS 7에 파워쉘을 설치합니다.

명령어: yum install powershell-6.0.0_alpha.9-1.el7.centos.x86_64.rpm

설치가 완료되면 다시 파우쉘이 정상적으로 설치되었는지 확인합니다.

명령어: rpm -qa | grep powershell

 

 

 

 

2. 파워쉘 명령어 실행하여 사용하기

다음과 같이 명령어를 통해 CentOS 7에서 파워쉘을 실행할 수 있습니다.

명령어: powershell

Get-Command 명령어를 실행한 결과

Get-ChildItem / 실행 시 화면

New-Item 명령어로 폴더 생성하기

Get-Process 명령어로 프로세스 조회하기

마지막으로 Get-Command 명령어를 통해 확인해보면 현재 CentOS 7에서 사용할 수 있는 명령어는 다음과 같습니다.

CommandType Name Version Source
Function Compress-Archive 1.0.1.0 Microsoft.PowerShell.Archive
Function Expand-Archive 1.0.1.0 Microsoft.PowerShell.Archive
Function Find-Command 1.0.0.1 PowerShellGet
Function Find-DscResource 1.0.0.1 PowerShellGet
Function Find-Module 1.0.0.1 PowerShellGet
Function Find-RoleCapability 1.0.0.1 PowerShellGet
Function Find-Script 1.0.0.1 PowerShellGet
Function Format-Hex 3.1.0.0 Microsoft.PowerShell.Utility
Function Get-FileHash 3.1.0.0 Microsoft.PowerShell.Utility
Function Get-InstalledModule 1.0.0.1 PowerShellGet
Function Get-InstalledScript 1.0.0.1 PowerShellGet
Function Get-PSRepository 1.0.0.1 PowerShellGet
Function Import-PowerShellDataFile 3.1.0.0 Microsoft.PowerShell.Utility
Function Install-Module 1.0.0.1 PowerShellGet
Function Install-Script 1.0.0.1 PowerShellGet
Function New-Guid 3.1.0.0 Microsoft.PowerShell.Utility
Function New-ScriptFileInfo 1.0.0.1 PowerShellGet
Function New-TemporaryFile 3.1.0.0 Microsoft.PowerShell.Utility
Function Publish-Module 1.0.0.1 PowerShellGet
Function Publish-Script 1.0.0.1 PowerShellGet
Function Register-PSRepository 1.0.0.1 PowerShellGet
Function Save-Module 1.0.0.1 PowerShellGet
Function Save-Script 1.0.0.1 PowerShellGet
Function Set-PSRepository 1.0.0.1 PowerShellGet
Function Test-ScriptFileInfo 1.0.0.1 PowerShellGet
Function Uninstall-Module 1.0.0.1 PowerShellGet
Function Uninstall-Script 1.0.0.1 PowerShellGet
Function Unregister-PSRepository 1.0.0.1 PowerShellGet
Function Update-Module 1.0.0.1 PowerShellGet
Function Update-ModuleManifest 1.0.0.1 PowerShellGet
Function Update-Script 1.0.0.1 PowerShellGet
Function Update-ScriptFileInfo 1.0.0.1 PowerShellGet
Cmdlet Add-Content 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Add-Member 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Add-Type 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Clear-Content 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Clear-Item 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Clear-ItemProperty 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Clear-Variable 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Compare-Object 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Convert-Path 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet ConvertFrom-Csv 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet ConvertFrom-Json 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet ConvertFrom-SecureString 3.0.0.0 Microsoft.PowerShell.Security
Cmdlet ConvertFrom-StringData 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet ConvertTo-Csv 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet ConvertTo-Json 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet ConvertTo-SecureString 3.0.0.0 Microsoft.PowerShell.Security
Cmdlet ConvertTo-Xml 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Copy-Item 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Copy-ItemProperty 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Debug-Process 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Debug-Runspace 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Disable-PSBreakpoint 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Disable-RunspaceDebug 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Enable-PSBreakpoint 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Enable-RunspaceDebug 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Export-Alias 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Export-Clixml 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Export-Csv 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Export-FormatData 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Format-Custom 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Format-List 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Format-Table 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Format-Wide 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Get-Alias 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Get-ChildItem 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Get-Content 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Get-Credential 3.0.0.0 Microsoft.PowerShell.Security
Cmdlet Get-Culture 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Get-Date 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Get-Event 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Get-EventSubscriber 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Get-ExecutionPolicy 3.0.0.0 Microsoft.PowerShell.Security
Cmdlet Get-FormatData 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Get-Host 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Get-Item 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Get-ItemProperty 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Get-ItemPropertyValue 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Get-Location 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Get-Member 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Get-Process 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Get-PSBreakpoint 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Get-PSCallStack 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Get-PSDrive 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Get-PSProvider 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Get-Random 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Get-Runspace 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Get-RunspaceDebug 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Get-TraceSource 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Get-TypeData 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Get-UICulture 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Get-Unique 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Get-Variable 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Group-Object 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Import-Alias 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Import-Clixml 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Import-Csv 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Import-LocalizedData 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Invoke-Expression 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Invoke-Item 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Invoke-RestMethod 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Invoke-WebRequest 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Join-Path 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Measure-Command 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Measure-Object 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Move-Item 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Move-ItemProperty 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet New-Alias 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet New-Event 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet New-Item 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet New-ItemProperty 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet New-Object 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet New-PSDrive 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet New-TimeSpan 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet New-Variable 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Out-File 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Out-String 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Pop-Location 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Push-Location 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Read-Host 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Register-EngineEvent 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Register-ObjectEvent 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Remove-Event 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Remove-Item 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Remove-ItemProperty 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Remove-PSBreakpoint 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Remove-PSDrive 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Remove-TypeData 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Remove-Variable 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Rename-Item 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Rename-ItemProperty 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Resolve-Path 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Select-Object 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Select-String 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Select-Xml 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Set-Alias 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Set-Content 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Set-Date 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Set-ExecutionPolicy 3.0.0.0 Microsoft.PowerShell.Security
Cmdlet Set-Item 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Set-ItemProperty 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Set-Location 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Set-PSBreakpoint 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Set-TraceSource 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Set-Variable 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Sort-Object 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Split-Path 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Start-Process 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Start-Sleep 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Start-Transcript 3.0.0.0 Microsoft.PowerShell.Host
Cmdlet Stop-Process 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Stop-Transcript 3.0.0.0 Microsoft.PowerShell.Host
Cmdlet Tee-Object 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Test-Path 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Trace-Command 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Unregister-Event 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Update-FormatData 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Update-TypeData 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Wait-Debugger 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Wait-Event 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Wait-Process 3.1.0.0 Microsoft.PowerShell.Management
Cmdlet Write-Debug 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Write-Error 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Write-Host 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Write-Information 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Write-Output 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Write-Progress 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Write-Verbose 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Write-Warning 3.1.0.0 Microsoft.PowerShell.Utility

윈도우에서 사용할 수 있는 파워쉘에 비해서는 아직 많이 부족하지만 점점 많은 기능과 모듈이 추가되면 파워쉘이 익순한 관리자나 사용자는 리눅스도 윈도우 환경에서도 같이 잘 사용할 수 있을것 같습니다. ^^

그럼 CentOS 7에 파워쉘을 설치하는 오늘의 포스팅을 마칩니다.

감사합니다.