New FAMILUG

The PyMiers

Friday 19 August 2016

[Windows] PowerShell đã đến thế giới *NIX

PowerShell là gì? 
PowerShell is an automation and configuration management platform. It consists of a cross-platform command-line shell and associated scripting language
Trên các hệ điều hành giống UNIX (*NIX) có sh, bash, fish, zsh ... thì trên M$ xưa nay chỉ có "cmd" - một shell thuộc loại vô cùng đơn giản. Gần đây, M$ đã phát triển PowerShell với những cải tiến vượt trội so với "cmd" cổ cũ.
Không biết "shell" là gì? xem thêm ở đây

Sau vài chục năm ghét mãi không xong, M$ (Microsoft) đã quay sang bày tỏ tình yêu với Linux


Các cụ dạy: "kẻ biết thời thế mới là anh hùng",
các cụ đã dạy chắc là không sai.

Đúng hay sai thì ai cũng thấy, M$ ngày càng được giới *NIX quan tâm hơn (ngay cả bài viết này), và người khổng lồ vẫn chưa ngã sau bao nhiêu sóng gió.
Ai từ chối thay đổi, sẽ phải chết, hoặc sống dè dè 😁

Bạn muốn trở thành Linux Sysadmin? thử bấm vào đây
Bạn muốn trở thành Windows Sysadmin? đóng 5 triệu rồi cũng bấm vào link trên🤓

Cài đặt (ubuntu 14.04)
sudo apt-get install libunwind8 libicu52
sudo dpkg -i powershell_6.0.0-alpha.9-1ubuntu1.14.04.1_amd64.deb
Cho Ubuntu 16.04, OSX... xem thêm ở đây

Dependencies:
$ dpkg -s powershell | grep -i depends (chạy sau khi đã cài đặt)
Depends: libunwind8, libicu52
libunwind8

$ apt-cache search libunwind8
libunwind8 - library to determine the call-chain of a program - runtime
Để đọc thêm chi tiết, gõ
apt-cache show libunwind8
libicu52 - hỗ trợ Unicode
$ apt-cache search libicu52
libicu52 - International Components for Unicode
Bảng chuyển đổi câu lệnh cho *NIX shell user:

BashPowerShell Description
ls dir, Get-ChildItem List files and folders
tree dir -Recurse List all files and folders
cd cd, Set-Location Change directory
pwd pwd, $pwd, Get-Location Show working directory
clear, Ctrl+L, reset cls, clear Clear screen
mkdir New-Item -ItemType Directory Create a new folder

Xem thêm tại: bảng chuyển đổi câu lệnh cho bash user

Thử câu lệnh *NIX nổi tiếng nhất mọi thời đại: RM
# powershell
PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

PS /root> New-Item -Path /tmp/test.txt  # như touch trên *NIX


    Directory: /tmp


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
------          8/19/16   2:28 AM              0 test.txt
PS /root> Remove-Item /tmp/test.txt  # như rm trên *NIX
PS /root>
Đánh giá ban đầu
- Có auto-complete
- Có màu mè
- Lệnh dài quá
 
Theo:
- https://azure.microsoft.com/en-us/blog/powershell-is-open-sourced-and-is-available-on-linux/
- https://github.com/PowerShell/PowerShell/tree/master/docs

No comments:

Post a Comment