自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

微軟愛上Linux:當PowerShell來到Linux時

系統(tǒng) Linux
在微軟愛上 Linux 之后,PowerShell 這個原本只是 Windows 才能使用的組件,于 2016 年 8 月 18 日開源并且成為跨平臺軟件,登陸了 Linux 和 macOS。

在微軟愛上 Linux 之后,PowerShell 這個原本只是 Windows 才能使用的組件,于 2016 年 8 月 18 日開源并且成為跨平臺軟件,登陸了 Linux 和 macOS。

PowerShell 是一個微軟開發(fā)的自動化任務(wù)和配置管理系統(tǒng)。它基于 .NET 框架,由命令行語言解釋器(shell)和腳本語言組成。

PowerShell 提供對 COM (組件對象模型Component Object Model) 和 WMI (Windows 管理規(guī)范Windows Management Instrumentation) 的完全訪問,從而允許系統(tǒng)管理員在本地或遠程 Windows 系統(tǒng)中 執(zhí)行管理任務(wù),以及對 WS-Management 和 CIM(公共信息模型Common Information Model)的訪問,實現(xiàn)對遠程 Linux 系統(tǒng)和網(wǎng)絡(luò)設(shè)備的管理。

通過這個框架,管理任務(wù)基本上由稱為 cmdlets(發(fā)音 command-lets)的 .NET 類執(zhí)行。就像 Linux 的 shell 腳本一樣,用戶可以通過按照一定的規(guī)則將一組 cmdlets 寫入文件來制作腳本或可執(zhí)行文件。這些腳本可以用作獨立的命令行程序或工具。

在 Linux 系統(tǒng)中安裝 PowerShell Core 6.0

要在 Linux 中安裝 PowerShell Core 6.0,我們將會用到微軟軟件倉庫,它允許我們通過***的 Linux 包管理器工具,如 apt-get、yum 等來安裝。

在 Ubuntu 16.04 中安裝

首先,導入該公共倉庫的 GPG 密鑰,然后將 Microsoft Ubuntu 倉庫注冊到 APT 的源中來安裝 PowerShell:

  1. $ curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - 
  2. $ curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list 
  3. $ sudo apt-get update 
  4. $ sudo apt-get install -y powershell 

在 Ubuntu 14.04 中安裝

  1. $ curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add - 
  2. $ curl https://packages.microsoft.com/config/ubuntu/14.04/prod.list | sudo tee /etc/apt/sources.list.d/microsoft.list 
  3. $ sudo apt-get update 
  4. $ sudo apt-get install -y powershell 

在 CentOS 7 中安裝

首先,將 Microsoft RedHat 倉庫注冊到 YUM 包管理器倉庫列表中,然后安裝 PowerShell:

  1. $ sudo curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/microsoft.repo 
  2. $ sudo yum install -y powershell 

如何在 Linux 中使用 PowerShell Core 6.0

在這一節(jié)中,我們將會簡單介紹下 PowerShell;我們將會看到如何啟動 PowerShell,運行一些基礎(chǔ)命令,操作文件、目錄和進程。然后學習怎樣列出所有可用的命令、顯示命令幫助和別名。

輸入以下命令來啟動 PowerShell:

  1. $ powershell 

 

微軟愛上Linux:當PowerShell來到Linux時

在 Linux 中啟動 PowerShell

你可以通過以下命令來查看 PowerShell 版本:

  1. $PSVersionTable 

 

微軟愛上Linux:當PowerShell來到Linux時

查看 PowerShell 版本

在 Linux 中運行基本的 PowerShell 命令。

  1. get-date          [# 顯示當前日期] 
  2. get-uptime        [# 顯示開機時間] 
  3. get-location      [# 顯示當前工作目錄] 

在 PowerShell 中操作文件和目錄

1、 可以通過兩種方法創(chuàng)建空文件:

  1. new-item  tecmint.tex 
  2. 或者 
  3. "">tecmint.tex 

然后往里面添加內(nèi)容并查看文件內(nèi)容。

  1. set-content tecmint.tex -value "TecMint Linux How Tos Guides" 
  2. get-content tecmint.tex 

 

微軟愛上Linux:當PowerShell來到Linux時

在 PowerShell 中創(chuàng)建新文件

2、 在 PowerShell 中刪除一個文件

  1. remove-item tecmint.tex 
  2. get-content tecmint.tex 

 

微軟愛上Linux:當PowerShell來到Linux時

在 PowerShell 中刪除一個文件

3、 創(chuàng)建目錄

  1. mkdir  tecmint-files 
  2. cd  tecmint-files 
  3. “”>domains.list 
  4. ls 

 

微軟愛上Linux:當PowerShell來到Linux時

在 PowerShell 中創(chuàng)建目錄

4、 執(zhí)行長格式的列表操作,列出文件/目錄詳細情況,包括模式(文件類型)、***修改時間等,使用以下命令:

  1. dir 

 

微軟愛上Linux:當PowerShell來到Linux時

Powershell 中列出目錄長列表

5、 顯示系統(tǒng)中所有的進程:

  1. get-process 

 

微軟愛上Linux:當PowerShell來到Linux時

在 PowerShell 中顯示運行中的進程

6、 通過給定的名稱查看正在運行的進程/進程組細節(jié),將進程名作為參數(shù)傳給上面的命令,如下:

  1. get-process apache2 

 

微軟愛上Linux:當PowerShell來到Linux時

在 PowerShell 中查看指定的進程

輸出中各部分的含義:

  • NPM(K) – 進程使用的非分頁內(nèi)存,單位:Kb。
  • PM(K) – 進程使用的可分頁內(nèi)存,單位:Kb。
  • WS(K) – 進程的工作集大小,單位:Kb,工作集由進程所引用到的內(nèi)存頁組成。
  • CPU(s) – 進程在所有處理器上所占用的處理器時間,單位:秒。
  • ID – 進程 ID (PID).
  • ProcessName – 進程名稱。

7、 想要了解更多,獲取 PowerShell 命令列表:

  1. get-command 

 

微軟愛上Linux:當PowerShell來到Linux時

列出 PowerShell 的命令

8、 想知道如何使用一個命令,查看它的幫助(類似于 Unix/Linux 中的 man);舉個例子,你可以這樣獲取命令 Describe 的幫助:

  1. get-help Describe 

 

微軟愛上Linux:當PowerShell來到Linux時

PowerShell 幫助手冊

9、 顯示所有命令的別名,輸入:

  1. get-alias 

 

微軟愛上Linux:當PowerShell來到Linux時

列出 PowerShell 命令別名

10、 ***,不過也很重要,顯示命令歷史記錄(曾運行過的命令的列表):

  1. history 

 

微軟愛上Linux:當PowerShell來到Linux時

顯示 PowerShell 命令歷史記錄

就是這些了!在這篇文章里,我們展示了如何在 Linux 中安裝微軟的 PowerShell Core 6.0。在我看來,與傳統(tǒng) Unix/Linux 的 shell 相比,PowerShell 還有很長的路要走。目前看來,PowerShell 還需要在命令行操作機器,更重要的是,編程(寫腳本)等方面,提供更好、更多令人激動和富有成效的特性。

作者簡介:

Aaron Kili 是一個 Linux 和 F.O.S.S 狂熱愛好者,將來的 Linux 系統(tǒng)管理員、web 開發(fā)者,目前是 TecMint 的內(nèi)容編輯,是一個熱愛研究計算機與堅定的分享知識的人。

責任編輯:未麗燕 來源: Linux中國
相關(guān)推薦

2016-11-22 17:26:11

開源PowerShellLinux

2016-08-22 12:17:56

PowerShellLinuxOS X

2020-05-21 11:23:08

微軟LinuxWindows

2012-03-16 15:35:21

.netJava

2015-08-24 11:33:43

Ubuntu LinuIBM大型機

2022-12-03 16:02:51

2020-03-18 14:20:25

shellLinux命令

2009-08-04 08:20:10

2011-04-08 10:30:27

2009-12-15 09:42:56

Linux微軟

2012-06-11 08:54:34

微軟Windows Sto

2011-04-08 10:31:24

Linux微軟

2011-08-24 09:43:06

ASP.NET MVC

2021-02-26 01:02:53

衛(wèi)星互聯(lián)網(wǎng)網(wǎng)絡(luò)寬帶

2009-09-10 09:29:09

Linux組織Linux微軟專利

2014-10-22 13:35:31

Linux微軟

2009-06-01 10:03:07

Linux兼容微軟

2015-07-28 10:14:40

Linux on PoPower極速

2009-12-04 09:57:02

微軟Linux

2010-01-14 10:16:04

微軟蘋果Linux
點贊
收藏

51CTO技術(shù)棧公眾號