Merge branch 'MichaelCade:main' into main

This commit is contained in:
Mau Ha Quang 2022-10-06 09:29:53 +09:00 committed by GitHub
commit e7f78fc93c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 322 additions and 357 deletions

View File

@ -1,80 +1,59 @@
---
title: '#90DaysOfDevOps - The Big Picture: DevOps and Linux - Day 14'
title: '#90DaysOfDevOps - 全体像の把握 DevOpsとLinux - 14日目'
published: false
description: 90DaysOfDevOps - The Big Picture DevOps and Linux
description: 90DaysOfDevOps - 全体像の把握 DevOpsとLinux
tags: 'devops, 90daysofdevops, learning'
cover_image: null
canonical_url: null
id: 1049033
---
## The Big Picture: DevOps and Linux
Linux and DevOps share very similar cultures and perspectives; both are focused on customization and scalability. Both of these aspects of Linux are of particular importance for DevOps.
A lot of technologies start on Linux, especially if they are related to software development or managing infrastructure.
## 全体像の把握 DevOpsとLinux
As well lots of open source projects, especially DevOps tools, were designed to run on Linux from the start.
LinuxとDevOpsは、非常によく似た文化と観点を共有しており、どちらもカスタマイズとスケーラビリティに重点を置いています。Linuxのこの2つの側面は、DevOpsにとって特に重要です。
From a DevOps perspective or in fact any operations role perspective you are going to come across Linux I would say mostly. There is a place for WinOps but the majority of the time you are going to be administering and deploying Linux servers.
特にソフトウェア開発やインフラストラクチャの管理に関連する場合、多くのテクロジーがLinuxから始まっています。
I have been using Linux on a daily basis for a number of years but my go to desktop machine has always been either macOS or Windows. However, when I moved into the Cloud Native role I am in now I took the plunge to make sure that my laptop was fully Linux based and my daily driver, whilst I still needed Windows for work-based applications and a lot of my audio and video gear does not run on Linux I was forcing myself to run a Linux desktop full time to get a better grasp of a lot of the things we are going to touch on over the next 7 days.
また、多くのオープン・ソース・プロジェクト、特にDevOpsツールは、最初からLinux上で動作するように設計されています。
## Getting Started
I am not suggesting you do the same as me by any stretch as there are easier options and less destructive but I will say taking that full-time step forces you to learn faster on how to make things work on Linux.
DevOpsの観点から、あるいは実際、運用の役割の観点から、あなたはLinuxに遭遇することになるでしょう。WinOpsもありますが、ほとんどの場合、Linuxサーバを管理、デプロイすることになります。
For the majority of these 7 days, I am actually going to deploy a Virtual Machine in Virtual Box on my Windows machine. I am also going to deploy a desktop version of a Linux distribution, whereas a lot of the Linux servers you will be administering will likely be servers that come with no GUI and everything is shell-based. However, as I said at the start a lot of the tools that we covered throughout this whole 90 days started out on Linux I would also strongly encourage you to take the dive into running that Linux Desktop for that learning experience as well.
私は何年も前からLinuxを日常的に使っていますが、デスクトップ・マシンはいつもmacOSかWindowsでした。しかし、現在のクラウド・ネイティブの職務に就いたとき、私は思い切って自分のラップトップを完全にLinuxベースにして日常的に使うようにした。仕事用のアプリケーションにはまだWindowsが必要だし、私のオーディオやビデオ機器の多くはLinuxでは動かないが、これから7日間にわたって触れる多くのことをよりよく理解するために、Linuxデスクトップをフルタイムで動かすことを自分に強いていた。
## はじめに
もっと簡単で破壊的でない選択肢もあるので、決して私と同じことをしろと言っているわけではありませんが、フルタイムのステップを踏むことで、Linuxで物事を動かす方法をより早く学ぶことができるということは言えると思います。
For the rest of this post, we are going to concentrate on getting a Ubuntu Desktop virtual machine up and running in our Virtual Box environment. Now we could just download [Virtual Box](https://www.virtualbox.org/) and grab the latest [Ubuntu ISO](https://ubuntu.com/download) from the sites linked and go ahead and build out our desktop environment but that wouldn't be very DevOps of us, would it?
この7日間の大半は、Windowsマシン上のVirtual BoxでVirtual Machineをデプロイするつもりです。一方、あなたが管理するLinuxサーバーの多くは、GUIがなく、すべてがシェルベースのサーバーでしょう。しかし、冒頭で言ったように、この90日間を通して取り上げたツールの多くはLinuxから始まっている。
この記事では、Virtual Box環境でUbuntuデスクトップの仮想マシンを立ち上げて実行することに集中します。Virtual Box](https://www.virtualbox.org/) をダウンロードし、リンク先のサイトから最新の [Ubuntu ISO](https://ubuntu.com/download) を入手して、デスクトップ環境を構築することもできますが、それではDevOpsらしくありませんよね
ほとんどのLinuxディストリビューションを使うもう一つの理由は、それらがフリーでオープンソースであることです。また、モバイルデバイスや企業のRedHat Enterpriseサーバーのことを考えず、おそらく最も広く使われているディストリビューションであるUbuntuを選んでいます。間違っているかもしれませんが、CentOSとその歴史から、Ubuntuが上位に来るのは間違いないと思いますし、超シンプルです。
Another good reason to use most Linux distributions is that they are free and open-source. We are also choosing Ubuntu as it is probably the most widely used distribution deployed not thinking about mobile devices and enterprise RedHat Enterprise servers. I might be wrong there but with CentOS and the history there I bet Ubuntu is high on the list and it's super simple.
## HashiCorp Vagrantのご紹介
Vagrant は、仮想マシンのライフサイクルを管理する CLI ユーティリティです。vagrant を使って vSphere、Hyper-v、Virtual Box、Docker など様々なプラットフォームで仮想マシンをスピンアップ、ダウンすることができます。他のプロバイダもありますが、ここではVirtual Boxを使用するので、これにこだわることにします。
まず、Vagrantをインストールします。ダウンロードページに行くと、すべてのOSがリストアップされています。[HashiCorp Vagrant](https://www.vagrantup.com/downloads) 私はWindowsを使用しているので、自分のシステム用のバイナリを取得し、システムにインストールしました。
## Introducing HashiCorp Vagrant
次に、[Virtual Box](https://www.virtualbox.org/wiki/Downloads)をインストールする必要があります。これもまた、様々なOSにインストールすることができます。Vagrantを選ぶ良い理由は、Windows、macOS、Linuxを使用しているのであれば、Vagrantでカバーできるということです。
どちらもインストールはとても簡単です。もし問題があれば、どちらも素晴らしいコミュニティがあるので、気軽に声をかけてください。
## 初のVAGRANTFILE
Vagrant is a CLI utility that manages the lifecycle of your virtual machines. We can use vagrant to spin up and down virtual machines across many different platforms including vSphere, Hyper-v, Virtual Box and also Docker. It does have other providers but we will stick with that we are using Virtual Box here so we are good to go.
The first thing we need to do is get Vagrant installed on our machine, when you go to the downloads page you will see all the operating systems listed for your choice. [HashiCorp Vagrant](https://www.vagrantup.com/downloads) I am using Windows so I grabbed the binary for my system and went ahead and installed this to my system.
Next up we also need to get [Virtual Box](https://www.virtualbox.org/wiki/Downloads) installed. Again this can also be installed on many different operating systems again a good reason to choose this and vagrant is that if you are running Windows, macOS, or Linux then we have you covered here.
Both installations are pretty straightforward. If you have issues both have great communities around them also feel free to reach out and I can try to assist also.
## Our first VAGRANTFILE
The VAGRANTFILE describes the type of machine we want to deploy. It also defines how we want the configuration and provisioning of this machine need to look.
When it comes to saving these and organizing your VAGRANTFILEs I tend to put them in their own folders in my workspace. You can see below how this looks on my system. Hopefully following this you will play around with Vagrant and see the ease of spinning up different systems, it is also great for that rabbit hole is known as distro hopping for Linux Desktops.
VAGRANTFILEは、配備したいマシンの種類を記述します。また、このマシンの設定とプロビジョニングがどのように見えるようにしたいかを定義します。
VAGRANTFILEを保存し、整理する場合、私はワークスペース内の独自のフォルダに入れることが多いです。私のシステムでは、以下のように表示されます。この後、Vagrant を使ってみて、様々なシステムを簡単に立ち上げることができることを期待しています。
![](Images/Day14_Linux1.png)
Let's take a look at that VAGRANTFILE then and see what we are building.
それでは、VAGRANTFILE を見て、何を構築しているのか見てみましょう。
```
Vagrant.configure("2") do |config|
config.vm.box = "chenhan/ubuntu-desktop-20.04"
@ -87,86 +66,59 @@ Vagrant.configure("2") do |config|
v.customize ["modifyvm", :id, "--vram", "128mb"]
end
end
end
```
This is a very simple VAGRANTFILE overall we are saying we want a specific "box" a box being possibly either a public image or private build of the system you are looking for. You can find a long list of "boxes" publicly available here in the [public catalog of Vagrant boxes](https://app.vagrantup.com/boxes/search)
Next line we are saying we want to use a specific provider in this case it is `VirtualBox` and then we want to define our machine's memory to `8GB and our number of CPUs to `4`. My experience also tells me that you may want to also add the following line if you experience display issues. This will set the video memory to what you want, I would ramp this right up to `128MB but depends on your system.
これは非常にシンプルなVAGRANTFILEで、特定の「ボックス」が欲しいと言っています。ボックスとは、あなたが探しているシステムのパブリックイメージかプライベートビルドのどちらかです。Vagrant boxes の[公開カタログ](https://app.vagrantup.com/boxes/search) に、公開されている "box" の一覧があります。
次の行では、特定のプロバイダ(この場合は `VirtualBox` )を使い、マシンのメモリを `8GB` に、CPU数を `4` に定義することを述べています。また、私の経験では、表示に問題がある場合は、次の行を追加するとよいでしょう。これはビデオメモリを設定するもので、私なら128MBまで増設しますが、システムによります。
```
v.customize ["modifyvm", :id, "--vram", ""]
```
I have also placed a copy of this specific vagrant file in the [Linux Folder](Linux/VAGRANTFILE)
## Provisioning our Linux Desktop
We are now ready to get our first machine up and running, in your workstations terminal. In my case I am using PowerShell on my Windows machine, navigate to your projects folder and where you will find your VAGRANTFILE. Once there you can type the command `vagrant up` and if everything is correct then you will see something like the below.
また、この特定のvagrantファイルのコピーを[Linux Folder](Linux/VAGRANTFILE)に置きました。
## Linuxデスクトップのプロビジョニング
ワークステーションのターミナルで、最初のマシンを立ち上げる準備ができました。私の場合、WindowsマシンでPowerShellを使用しています。プロジェクトフォルダに移動して、VAGRANTFILEを見つけます。そこで、`vagrant up`コマンドを入力し、すべてが正しく行われていれば、以下のような画面が表示されます。
![](Images/Day14_Linux2.png)
もう一つ、仮想マシンのネットワークは`NAT`に設定されます。この段階では、NATについて知る必要はありませんし、次のネットワークについてのセッションで説明する予定です。NATはVirtual Boxのデフォルトのネットワークモードでもあり、ホームネットワークにマシンを接続するための簡単なボタンです。詳しくは[Virtual Box documentation](https://www.virtualbox.org/manual/ch06.html#network_nat)で確認できます。
Another thing to add here is that the network will be set to `NAT` on your virtual machine, at this stage we don't really need to know about NAT and I plan to have a whole session talking about in the next section about Networking. But know that it is the easy button when it comes to getting a machine on your home network, it is also the default networking mode on Virtual Box. You can find out more in the [Virtual Box documentation](https://www.virtualbox.org/manual/ch06.html#network_nat)
Once `vagrant up` is complete we can now use `vagrant ssh` to jump straight into the terminal of our new VM.
`vagrant up`が完了したら、今度は `vagrant ssh`を使って新しいVMの端末に直接アクセスできるようにします。
![](Images/Day14_Linux3.png)
これから数日間、私たちはほとんどここを探索することになりますが、私が行った開発者用ワークステーションのカスタマイズについても紹介したいと思いますし、これを毎日のドライバとして実行すると生活がずっとシンプルになります。
This is where we will do most of our exploring over the next few days but I also want to dive into some customizations for your developer workstation that I have done and it makes your life much simpler when running this as your daily driver, and of course, are you really in DevOps unless you have a cool nonstandard terminal?
But just to confirm in Virtual Box you should see the login prompt when you select your VM.
ただし、Virtual Boxでは、VMを選択するとログインプロンプトが表示されるはずですので、ご確認ください。
![](Images/Day14_Linux4.png)
Oh and if you made it this far and you have been asking "WHAT IS THE USERNAME & PASSWORD?"
ここまで来て、「USERNAMEとPASSWORD」は何ですか
- Username = vagrant
- Password = vagrant
明日は、いくつかのコマンドとその機能について説明しますが、ターミナルはすべてを実現する場所となります。
Tomorrow we are going to get into some of the commands and what they do, The terminal is going to be the place to make everything happen.
## Resources
## リソース
- [Learn the Linux Fundamentals - Part 1](https://www.youtube.com/watch?v=kPylihJRG70)
- [Linux for hackers (don't worry you don't need be a hacker!)](https://www.youtube.com/watch?v=VbEx7B_PTOE)
There are going to be lots of resources I find as we go through and much like the Go resources I am generally going to be keeping them to FREE content so we can all partake and learn here.
Goのリソースと同じように、私たちがここで参加し学ぶことができるように、私は一般的にそれらを無料のコンテンツに保つつもりです。
As I mentioned next up we will take a look at the commands we might be using on a daily whilst in our Linux environments.
次はLinux環境で毎日使うようなコマンドを見ていこうと思います。
See you on [Day15](day15.md)
[15日目](day15.md)でお会いしましょう。

View File

@ -1,116 +1,121 @@
---
title: '#90DaysOfDevOps - Linux Commands for DevOps (Actually everyone) - Day 15'
title: '#90DaysOfDevOps - DevOpsのためのLinuxコマンド - 15日目'
published: false
description: 90DaysOfDevOps - Linux Commands for DevOps (Actually everyone)
description: 90DaysOfDevOps - DevOpsのためのLinuxコマンド
tags: "devops, 90daysofdevops, learning"
cover_image: null
canonical_url: null
id: 1048834
---
## Linux Commands for DevOps (Actually everyone)
I mentioned it [yesterday](day14.md) that we are going to be spending a lot of time in the terminal with some commands to get stuff done.
## DevOpsのためのLinuxコマンド
I also mentioned that with our vagrant provisioned VM we can use `vagrant ssh` and gain access to our box. You will need to be in the same directory as we provisioned it from.
[昨日](day14.md)、私たちはターミナルで多くの時間を費やしてコマンドを実行することになるだろうと書きました。
For SSH you won't need the username and password, you will only need that if you decide to login to the Virtual Box console.
また、Vagrant でプロビジョニングした VM で `vagrant ssh` を使って、私たちのマシンにアクセスできることを述べました。プロビジョニングしたのと同じディレクトリにいる必要があります。
This is where we want to be as per below:
SSHではユーザー名とパスワードは不要です。Virtual Boxのコンソールにログインする場合のみ必要です。
このディレクトリは以下のようになります。
![](Images/Day15_Linux1.png)
## Commands
## コマンド
Obviously I cannot cover all the commands here, there are pages and pages of documentation that cover these but also if you are ever in your terminal and you just need to understand options to a specific command we have the `man` pages short for manual. We can use this to go through each of the commands we touch on during this post to find out more options for each one. We can run `man man` which will give you the help for manual pages. To escape the man pages you should press `q` for quit.
もちろん、ここですべてのコマンドをカバーすることはできません。これらのコマンドをカバーするドキュメントは何ページもありますが、ターミナルで特定のコマンドのオプションを理解する必要がある場合、マニュアルを短くした `man` ページがあります。この記事で触れた各コマンドについて、このページを使ってさらに詳しいオプションを確認することができます。`man man`を実行すると、マニュアルページのヘルプが表示されます。マニュアルページから抜けるには、`q`を押してください。
![](Images/Day15_Linux2.png)
![](Images/Day15_Linux3.png)
`sudo` If you are familar with Windows and the right click `run as administrator` we can think of `sudo` as very much this. When you run a command with this command you will be running it as `root` it will prompt you for the password before running the command.
`sudo` Windows や右クリックの `管理者として実行` に慣れているなら、`sudo` はまさにこれだと考えることができます。このコマンドでコマンドを実行すると、`root`として実行することになり、コマンドを実行する前にパスワードの入力が要求されます。
![](Images/Day15_Linux4.png)
For one off jobs like installing applications or services you might need that `sudo command` but what if you have several tasks to deal with and you want to live as `sudo` for a while? This is where you can use `sudo su` again the same as `sudo` once entered you will be prompted for your `root` password. In a test VM like ours this is fine but I would find it very hard for us to be rolling around as `root` for prolonged periods, bad things can happen. To get out of this elevated position you simply type in `exit`
アプリケーションやサービスをインストールするような単発の作業では `sudo コマンド` が必要かもしれませんが、いくつかの作業があり、しばらくの間 `sudo` として生活したい場合はどうすればいいでしょうか。この場合、`sudo su` を使用します。`sudo` と同じように、一度入力すると `root` パスワードを要求されます。私たちのようなテスト用VMでは問題ありませんが、長時間`root`として動き回るのは大変なことです。この高い位置から抜け出すには、単に `exit` と入力してください。
![](Images/Day15_Linux5.png)
I find myself using `clear` all the time, the `clear` command does exactly what it says it is going to clear the screen of all previous commands, putting your prompt to the top and giving you a nice clean workspace. Windows I think is `cls` in the .mdprompt.
私はいつも `clear` を使っています。`clear` コマンドはその名の通り、それまでのコマンドをすべて消去し、プロンプトを一番上に持ってきて、きれいなワークスペースにします。Windows では .mdprompt にある `cls` がそうだと思います。
![](Images/Day15_Linux6.png)
Let's now look at some commands where we can actually create things within our system and then visualise them in our terminal, first of all we have `mkdir` this will allow us to create a folder in our system. With the following command we can create a folder in our home directory called Day15 `mkdir Day15`
まず最初に `mkdir` を使ってシステム内にフォルダーを作成します。次のコマンドで、ホームディレクトリに Day15 という名前のフォルダを作成することができます。
![](Images/Day15_Linux7.png)
With `cd` this allows us to change directory, so for us to move into our newly created directory we can do this with `cd Day15` tab can also be used to autocomplete the directory available. If we want to get back to where we started we can use `cd ..`
`cd` を使用すると、ディレクトリを変更することができます。新しく作成したディレクトリに移動するには、 `cd Day15` タブを使用して、使用可能なディレクトリを自動で補完することができます。もし、最初に作ったディレクトリに戻りたい場合は、 `cd ..` を使用します。
![](Images/Day15_Linux8.png)
`rmdir` allows for us to remove the directory, if we run `rmdir Day15` then the folder will be removed (note that this will only work if you have nothing in the folder)
`rmdir` でディレクトリを削除できます。`rmdir Day15` を実行すると、フォルダが削除されます (フォルダに何も入っていない場合のみ動作することに注意してください)。
![](Images/Day15_Linux9.png)
I am sure we have all done it where we have navigated to the depths of our file system to a directory and not known where we are. `pwd` gives us the print out of the working directory, pwd as much as it looks like password it stands for print working directory.
私たちは皆、ファイルシステムの奥深くにあるディレクトリまで移動し、どこにいるのかわからなくなったことがあると思います。pwd` は作業ディレクトリを表示します。pwd はパスワードのように見えますが、print working directory の略です。
![](Images/Day15_Linux10.png)
We know how to create folders and directories but how do we create files? We can create files using the `touch` command if we were to run `touch Day15` this would create a file. Ignore `mkdir` we are going see this again later.
フォルダやディレクトリを作成する方法は知っていますが、ファイルを作成するにはどうしたらよいのでしょうか?ファイルを作るには `touch` コマンドを使います。例えば、`touch Day15` と実行すると、ファイルが作成されます。mkdir` は無視してください、後でまた見ることになります。
![](Images/Day15_Linux11.png)
`ls` I can put my house on this, you will use this command so many times, this is going to list the all the files and folders in the current directory. Let's see if we can see that file we just created.
このコマンドは、カレントディレクトリにあるすべてのファイルとフォルダーをリストアップしてくれます。先ほど作成したファイルが見えるかどうか見てみましょう。
![](Images/Day15_Linux12.png)
How can we find files on our Linux system? `locate` is going to allow us to search our file system. If we use `locate Day15` it will report back that location of the file. Bonus round is that if you know that the file does exist but you get a blank result then run `sudo updatedb` which will index all the files in the file system then run your `locate` again. If you do not have `locate` available to you, you can install it using this command `sudo apt install mlocate`
Linux システムでファイルを探すにはどうしたらいいのでしょうか?`locate` を使うと、ファイルシステムを検索することができます。もし `locate Day15` を使うと、そのファイルの場所が報告されます。ボーナスラウンドとして、もしファイルが存在することが分かっているのに空白の結果が返ってきたら、 `sudo updatedb` を実行して、ファイルシステム内のすべてのファイルのインデックスを作成して、もう一度 `locate` を実行してみてください。もし `locate` がない場合は、次のコマンドでインストールすることができます ( `sudo apt install mlocate` )。
![](Images/Day15_Linux13.png)
What about moving files from one location to another? `mv` is going to allow you to move your files. Example `mv Day15 90DaysOfDevOps` will move your file to the 90DaysOfDevOps folder.
ある場所から別の場所にファイルを移動するのはどうでしょうか。`mv`を使うとファイルを移動することができます。例:`mv Day15 90DaysOfDevOps` は 90DaysOfDevOps フォルダにファイルを移動します。
![](Images/Day15_Linux14.png)
We have moved our file but what if we want to rename it now to something else? We can do that using the `mv` command again... WOT!!!? yep we can simply use `mv Day15 day15` to change to upper case or we could use `mv day15 AnotherDay` to change it altogether, now use `ls` to check the file.
ファイルを移動させましたが、今度は別の名前に変えたいとしたらどうしますか?それはまた `mv` コマンドを使えばいいのです...。`mv day15 day15` を使って大文字にしたり、`mv day15 AnotherDay` を使って完全に変更することができます。
![](Images/Day15_Linux15.png)
Enough is enough, let's now get rid (delete)of our file and maybe even our directory if we have one created. `rm` simply `rm AnotherDay` will remove our file. We will also use quite a bit `rm -R` which will recursively work through a folder or location. We might also use `rm -R -f` to force the removal of all of those files. Spoiler if you run `rm -R -f /` add sudo to it and you can say goodbye to your system....!
もう十分なので、ファイルやディレクトリを削除してしまいましょう。単純に `rm AnotherDay` を実行すると、ファイルが削除されます。また、`rm -R` もよく使います。これはフォルダや場所を再帰的に操作してくれます。また、`rm -R -f` を使って、すべてのファイルを強制的に削除することもできます。ネタバレ `rm -R -f /` を実行したら、sudo を追加して、あなたのシステムに別れを告げることができます......!
![](Images/Day15_Linux16.png)
We have looked at moving files around but what if I just want to copy files from one folder to another, simply put its very similar to the `mv` command but we use `cp` so we can now say `cp Day15 Desktop`
これまでファイルの移動について見てきましたが、単にあるフォルダから別のフォルダにファイルをコピーしたい場合はどうすればいいでしょうか。簡単に言うと、`mv`コマンドに非常に似ていますが、`cp`を使用するので、`cp Day15 Desktop`と言うことができます。
![](Images/Day15_Linux17.png)
We have created folders and files but we haven't actually put any contents into our folder, we can add contents a few ways but an easy way is `echo` we can also use `echo` to print out a lot of things in our terminal, I personally use echo a lot to print out system variables to know if they are set or not at least. we can use `echo "Hello #90DaysOfDevOps" > Day15` and this will add this to our file. We can also append to our file using `echo "Commands are fun!" >> Day15`
フォルダとファイルを作成しましたが、実際にはまだ中身を入れていません。中身を入れるにはいくつかの方法がありますが、簡単な方法は `echo` を使うことです。また、`echo "Commands are fun!" を使ってファイルに追加することもできます。>> Day15`
![](Images/Day15_Linux18.png)
Another one of those commands you will use a lot! `cat` short for concatenate. We can use `cat Day15` to see the contents inside the file. Great for quickly reading those configuration files.
もう一つ、よく使うコマンドを紹介しましょう。`cat` は concatenate の略です。ファイルの中身を見るには、`cat Day15`を使う。設定ファイルを素早く読むのに最適だ。
![](Images/Day15_Linux19.png)
If you have a long complex configuration file and you want or need to find something fast in that file vs reading every line then `grep` is your friend, this will allow us to search your file for a specific word using `cat Day15 | grep "#90DaysOfDevOps"`
もし、長い複雑な設定ファイルを持っていて、すべての行を読むよりも早く何かを見つけたい場合、 `grep` はあなたの味方です。これは、 `cat Day15 | grep "#90DaysOfDevOps"` のように特定の単語を探すためにファイルを検索することを可能にしてくれます。
![](Images/Day15_Linux20.png)
If you are like me and you use that `clear` command a lot then you might miss some of the commands previously ran, we can use `history` to find out all those commands we have run prior. `history -c` will remove the history.
私のように `clear` コマンドをよく使う場合、以前に実行したコマンドを見逃すことがあります。そのような場合は、`history` を使って以前に実行したコマンドをすべて確認することができます。history -c` を実行すると、履歴を削除することができます。
When you run `history` and you would like to pick a specific command you can use `!3` to choose the 3rd command in the list.
また、 `history` を実行したときに、特定のコマンドを選択したい場合は、 `!3` を使用すると、リストの3番目のコマンドを選択することができます。
You are also able to use `history | grep "Command` to search for something specific.
また、`history | grep "Command` を使って、特定のものを検索することもできます。
On servers to trace back when was a command executed, it can be useful to append the date and time to each command in the history file.
サーバー上で、あるコマンドがいつ実行されたかを追跡するために、履歴ファイル内の各コマンドに日付と時刻を追加すると便利な場合があります。
次のシステム変数がこの動作を制御します。
The following system variable controls this behaviour:
```
HISTTIMEFORMAT="%d-%m-%Y %T "
```
You can easily add to your bash_profile:
bash_profileに簡単に追加することができます。
```
echo 'export HISTTIMEFORMAT="%d-%m-%Y %T "' >> ~/.bash_profile
```
So as useful to allow the history file grow bigger:
そのため、履歴ファイルが大きくなっても大丈夫です。
```
echo 'export HISTSIZE=100000' >> ~/.bash_profile
@ -119,25 +124,26 @@ echo 'export HISTFILESIZE=10000000' >> ~/.bash_profile
![](Images/Day15_Linux21.png)
Need to change your password? `passwd` is going allow us to change our password. Note that when you add your password in like this when it is hidden it will not be shown in `history` however if your command has `-p PASSWORD` then this will be visible in your `history`.
パスワードを変更する必要がありますかpasswd` はパスワードを変更することができます。このようにパスワードを追加したとき、それが非表示になっていると `history` に表示されないことに注意してください。しかし、コマンドに `-p PASSWORD` が含まれていると、 `history` に表示されるようになります。
![](Images/Day15_Linux22.png)
We might also want to add new users to our system, we can do this with `useradd` we have to add the user using our `sudo` command, we can add a new user with `sudo useradd NewUser`
また、新しいユーザーをシステムに追加したいと思うかもしれません。そのためには `useradd` コマンドを使用してユーザーを追加します。
![](Images/Day15_Linux23.png)
Creating a group again requires `sudo` and we can use `sudo groupadd DevOps` then if we want to add our new user to that group we can do this by running `sudo usermod -a -G DevOps` `-a` is add and `-G` is group name.
グループを作成するためには `sudo` が必要で、`sudo groupadd DevOps` を使用します。
そして、新しいユーザーをそのグループに追加したい場合は、`sudo usermod -a -G DevOps` を実行することでこれを行うことができます。
![](Images/Day15_Linux24.png)
How do we add users to the `sudo` group, this would be a very rare occassion for this to happen but in order to do this it would be `usermod -a -G sudo NewUser`
ユーザーを `sudo` グループに追加するにはどうすればいいのでしょうか。このようなことが起こるのは非常に稀ですが、これを行うには、`usermod -a -G sudo NewUser` とします。
### Permissions
### アクセス権
read, write and execute are the permissions we have on all of our files and folders on our Linux system.
read, write, executeは、Linuxシステム上のすべてのファイルやフォルダーに与えられている権限です。
A full list:
全リストです。
- 0 = None `---`
- 1 = Execute only `--X`
@ -148,46 +154,46 @@ A full list:
- 6 = Read & Write `RW-`
- 7 = Read, Write & Execute `RWX`
You will also see `777` or `775` and these represent the same numbers as the list above but each one represents **User - Group - Everyone**
また、`777`や`775`も表示されますが、これらは上記のリストと同じ番号を表し、それぞれが**User - Group - Everyone**を表しています。
Let's take a look at our file. `ls -al Day15` you can see the 3 groups mentioned above, user and group has read & write but everyone only has read.
ファイルを見てみましょう。ls -al Day15` 上記3つのグループが表示され、ユーザーとグループは読み込みと書き込みが可能ですが、Everyoneは読み込みのみです。
![](Images/Day15_Linux25.png)
We can change this using `chmod` you might find yourself doing this if you are creating binaries a lot on your systems as well and you need to give the ability to execute those binaries. `chmod 750 Day15` now run `ls -al Day15` if you want to run this for a whole folder then you can use `-R` to recursively do that.
`chmod` を使ってこれを変更することができます。バイナリをたくさん作っていて、そのバイナリを実行できるようにする必要がある場合、これを行うことになるでしょう。`chmod 750 Day15` これで `ls -al Day15` が実行されます。もしこれをフォルダ全体に対して実行したい場合は、 `-R` を使って再帰的に実行できます。
![](Images/Day15_Linux26.png)
What about changing the owner of the file? We can use `chown` for this operation, if we wanted to change the ownership of our `Day15` from user `vagrant` to `NewUser` we can run `sudo chown NewUser Day15` again `-R` can be used.
ファイルの所有者を変更するにはどうすればいいでしょうか?この操作には `chown` が使えます。例えば、`Day15` の所有者をユーザ `vagrant` から `NewUser` に変更したい場合は、`sudo chown NewUser Day15` を実行します。この場合も `-R` が使用できます。
![](Images/Day15_Linux27.png)
A command that you will come across is `awk` where this comes in real use is when you have an output that you only need specific data from. like running `who` we get lines with information, but maybe we only need the names. We can run `who | awk '{print $1}'` to get just a list of that first column.
このコマンドが本当に役に立つのは、特定のデータだけが必要な出力があるときです。 たとえば、`who` を実行すると情報が書かれた行が表示されますが、名前だけが必要かもしれません。`who | awk '{print $1}'` を実行すると、その最初の列のリストだけを得ることができます。
![](Images/Day15_Linux28.png)
If you are looking to read streams of data from standard input, then generates and executes command lines; meaning it can take output of a command and passes it as argument of another command. `xargs` is a useful tool for this use case. If for example I want a list of all the Linux user accounts on the system I can run. `cut -d: -f1 < /etc/passwd` and get the long list we see below.
もし、標準入力からデータのストリームを読み込もうとしているなら、コマンドラインを生成して実行します。つまり、あるコマンドの出力を受け取り、それを別のコマンドの引数として渡すことができるのです。`xargs` はこのような場合に便利なツールです。例えば、システム上のすべてのLinuxユーザアカウントのリストが欲しい場合、次のように実行できます。`cut -d: -f1 < /etc/passwd`を実行すると、以下のような長いリストが得られます。
![](Images/Day15_Linux29.png)
If I want to compact that list I can do so by using `xargs` in a command like this `cut -d: -f1 < /etc/passwd | sort | xargs`
もしこのリストをコンパクトにしたい場合は、次のようなコマンドで `xargs` を使用することで実現できます。
![](Images/Day15_Linux30.png)
I didn't mention the `cut` command either, this allows us to remove sections from each line of a file. It can be used to cut parts of a line by byte position, character and field. The `cut -d " " -f 2 list.txt` command allows us to remove that first letter we have and just display our numbers. There are so many combinations that can be used here with this command, I am sure I have spent too much time trying to use this command when I could have extracted data quicker manually.
また、`cut`コマンドについても触れていませんが、これはファイルの各行からセクションを削除することができます。これは、ファイルの各行からセクションを削除することができます。バイト位置、文字、フィールドによって行の一部をカットするために使用することができます。`cut -d " " -f 2 list.txt` コマンドを使えば、最初の文字を削除して、数字だけを表示させることができます。このコマンドは非常に多くの組み合わせが可能で、私はこれまで、手動でデータを素早く抽出できたはずなのに、このコマンドを使おうとして多くの時間を費やしてきたと思います。
![](Images/Day15_Linux31.png)
Also to note if you type a command and you are no longer with happy with it and you want to start again just hit control + c and this will cancel that line and start you fresh.
また、あるコマンドを入力した後、そのコマンドに満足できず、もう一度やり直したい場合は、control + cを押すだけで、その行がキャンセルされ、新しくやり直すことができます。
## Resources
## リソース
- [Learn the Linux Fundamentals - Part 1](https://www.youtube.com/watch?v=kPylihJRG70)
- [Linux for hackers (don't worry you don't need be a hacker!)](https://www.youtube.com/watch?v=VbEx7B_PTOE)
See you on [Day16](day16.md)
[16日目](day16.md)でお会いしましょう。
This is a pretty heavy list already but I can safely say that I have used all of these commands in my day to day, be it from an administering Linux servers or in my Linux Desktop, it is very easy when you are in Windows or macOS to navigate the UI but in Linux Servers they are not there, everything is done through the terminal.
WindowsやmacOSではUIを操作するのは簡単ですが、Linuxサーバーではそれがなく、全てターミナルで行います。

View File

@ -1,165 +1,166 @@
---
title: '#90DaysOfDevOps - Managing your Linux System, Filesystem & Storage - Day 16'
title: '#90DaysOfDevOps - Linuxシステム、ファイルシステム、ストレージの管理 - 16日目'
published: false
description: '90DaysOfDevOps - Managing your Linux System, Filesystem & Storage'
description: '90DaysOfDevOps - Linuxシステム、ファイルシステム、ストレージの管理'
tags: "devops, 90daysofdevops, learning"
cover_image: null
canonical_url: null
id: 1048702
---
## Managing your Linux System, Filesystem & Storage
So far we have had a brief overview of Linux and DevOps and then we got our lab environment set up using vagant [(Day 14)](day14.md), we then touched on a small portion of commands that will be in your daily toolkit when in the terminal and getting things done [(Day 15)](day15.md).
## Linuxシステム、ファイルシステム、ストレージの管理
Here we are going to look into three key areas of looking after your Linux systems with updates, installing software, understanding what system folders are used for and we will also take a look at storage.
これまで、Linux と DevOps の簡単な概要を説明し、vagrant を使ってラボ環境をセットアップしました [Day 14](day14.md) 。そして、ターミナルで物事を成し遂げるときに毎日使うツールキットのコマンドのごく一部に触れました [Day 15](day15.md) 。
## Managing Ubuntu & Software
ここでは、Linux システムのアップデート、ソフトウェアのインストール、システムフォルダの用途の理解、そしてストレージの3つの重要な領域について見ていきたいと思います。
The first thing we are going to look at is how we update our operating system. Most of you will be familiar with this process in a Windows OS and macOS, this looks slightly different on a Linux desktop and server.
## Ubuntuとソフトウェアの管理
We are going to be looking at the apt package manager, this is what we are going to use on our Ubuntu VM for updates and software installation.
まず最初に、オペレーティング・システムのアップデート方法について説明します。Windows OS や macOS では、このプロセスはよく知られていますが、Linux デスクトップやサーバでは少し違ってきます。
Generally, at least on dev workstations, I run this command to make sure that I have the latest available updates from the central repositories, before any software installation.
ここでは、aptパッケージマネージャについて見ていきます。これは、Ubuntu VMでアップデートとソフトウェアのインストールに使用するものです。
一般的に、少なくとも開発用ワークステーションでは、ソフトウェアをインストールする前に、中央リポジトリから最新の利用可能なアップデートがあることを確認するために、このコマンドを実行することにしています。
`sudo apt-get update`
![](Images/Day16_Linux1.png)
Now we have an updated Ubuntu VM with the latest OS updates installed. We now want to get some software installed here.
これで、最新のOSアップデートがインストールされたUbuntuのVMができました。ここで、いくつかのソフトウェアをインストールしたいと思います。
Let's choose `figlet` which is a program that generates text banners.
ここでは、テキストバナーを生成するプログラムである `figlet` を選択しましょう。
If we type `figlet` in our terminal you are going to see that we do not have it installed on our system.
ターミナルで`figlet`と入力すると、システムにインストールされていないことがわかります。
![](Images/Day16_Linux2.png)
You will see from the above though that it does give us some `apt` install options that we could try. This is because in the default repositories there is a program called figlet. Let's try `sudo apt install figlet`
しかし、上記のように `apt` のインストールオプションが表示されるので、それを試してみることができます。これは、デフォルトのレポジトリに figlet というプログラムがあるからです。 それでは、`sudo apt install figlet`を試してみましょう。
![](Images/Day16_Linux3.png)
We can now use our `figlet` app as you can see below.
これで、以下のように `figlet` アプリを使用することができます。
![](Images/Day16_Linux4.png)
If we want to remove that or any of our software installations we can also do that via the `apt` package manager.
もし、インストールしたソフトウェアを削除したい場合は、`apt`パッケージマネージャを使用して削除することもできます。
`sudo apt remove figlet`
![](Images/Day16_Linux5.png)
There are third party repositories that we can also add to our system, the ones we have access to out of the box are the Ubuntu default repositories.
サードパーティのリポジトリもありますが、Ubuntuのデフォルトのリポジトリにアクセスすることができます。
If for example, we wanted to install vagrant on our Ubuntu VM we would not be able to right now and you can see this below on the first command issued. We then add the key to trust the HashiCorp repository, then add the repository to our system.
例えば、UbuntuのVMにvagrantをインストールしたい場合、今はできません。次に、HashiCorpのリポジトリを信頼するためのキーを追加し、リポジトリをシステムに追加します。
![](Images/Day16_Linux6.png)
Once we have the HashiCorp repository added we can go ahead and run `sudo apt install vagrant` and get vagrant installed on our system.
HashiCorpのリポジトリを追加したら、`sudo apt install vagrant`を実行して、システムにvagrantをインストールします。
![](Images/Day16_Linux7.png)
There are so many options when it comes to software installation, different options for package managers, built into Ubuntu we could also use snaps for our software installations.
ソフトウェアのインストールには多くの選択肢があり、Ubuntuに組み込まれているパッケージマネージャやスナップを使ってインストールすることもできます。
Hopefully, this gives you a feel about how to manage your OS and software installations on Linux.
LinuxでOSやソフトウェアのインストールを管理する方法について感じていただければ幸いです。
## File System Explained
## ファイルシステムの説明
Linux is made up of configuration files, if you want to change anything then you change these configuration files.
Linuxは設定ファイルで構成されており、何かを変更したい場合は、この設定ファイルを変更することになります。
On Windows, you have C: drive and that is what we consider the root. On Linux we have `/` this is where we are going to find the important folders on our Linux system.
Windowsでは、C:ドライブがあり、これがルートとみなされます。Linuxでは、`/`があり、ここにLinuxシステム上の重要なフォルダがあります。
![](Images/Day16_Linux8.png)
- `/bin` - Short for binary, the bin folder is where our binaries that your system needs, executables and tools will mostly be found here.
- `/bin` - バイナリーの略で、システムが必要とするバイナリー、実行ファイル、ツールはほとんどここにあります。
![](Images/Day16_Linux9.png)
- `/boot` - All the files your system needs to boot up. How to boot up, and what drive to boot from.
- `/boot` - システムが起動するために必要なすべてのファイル。起動の仕方、起動するドライブ。
![](Images/Day16_Linux10.png)
- `/dev` - You can find device information here, this is where you will find pointers to your disk drives `sda` will be your main OS disk.
- `/dev` - デバイスの情報はここにあります。ここにはディスクドライブのポインタがあり、`sda`はOSのメインディスクになります。
![](Images/Day16_Linux11.png)
- `/etc` Likely the most important folder on your Linux system, this is where the majority of your configuration files.
- `/etc` - Linuxシステムで最も重要なフォルダであり、設定ファイルの大部分がここにあります。
![](Images/Day16_Linux12.png)
- `/home` - this is where you will find your user folders and files. We have our vagrant user folder. This is where you will find your `Documents` and `Desktop` folders that we worked in for the commands section.
- `/home` - この中にユーザーフォルダとファイルがあります。私たちのvagrantユーザーフォルダがあります。ここには、コマンドのセクションで作業した `Documents``Desktop` フォルダがあります。
![](Images/Day16_Linux13.png)
- `/lib` - We mentioned that `/bin` is where our binaries and executables live, `/lib` is where you will find the shared libraries for those.
- `/lib` - バイナリや実行ファイルがあるのが `/bin` で、それらの共有ライブラリがあるのが `/lib` であると述べました。
![](Images/Day16_Linux14.png)
- `/media` - This is where we will find removable devices.
- `/media` - ここで、リムーバブルデバイスを見つけることができます。
![](Images/Day16_Linux15.png)
- `/mnt` - This is a temporary mount point. We will cover more here in the next storage section.
- `/mnt` - これは一時的なマウントポイントです。ここについては、次のストレージのセクションで詳しく説明します。
![](Images/Day16_Linux16.png)
- `/opt` - Optional software packages. You will notice here that we have some vagrant and virtual box software stored here.
- `/opt` - オプションのソフトウェアパッケージです。ここに、vagrantやvirtual boxのソフトウェアが格納されていることに気づきます。
![](Images/Day16_Linux17.png)
- `/proc` - Kernel & process information, similar to `/dev`
- `/proc` - カーネルとプロセスの情報、`/dev`に似ている。
![](Images/Day16_Linux18.png)
- `/root` - To gain access you will need to sudo into this folder. The home folder for root.
- `/root` - アクセスするには、このフォルダにsudoする必要があります。rootのホームフォルダです。
![](Images/Day16_Linux19.png)
- `/run` -Placeholder for application states.
- `/run` - アプリケーションの状態を表すプレースホルダーです。
![](Images/Day16_Linux20.png)
- `/sbin` - Sudo bin, similar to the bin folder but these tools are intended for elevated superuser privileges on the system.
- `/sbin` - Sudo binは、binフォルダと似ていますが、これらのツールは、システム上で昇格したスーパーユーザー特権を対象としています。
![](Images/Day16_Linux21.png)
- `/tmp` - temporary files.
- `/tmp` - 一時ファイル
![](Images/Day16_Linux22.png)
- `/usr` - If we as a standard user have installed software packages it would generally be installed in the `/usr/bin` location.
- `/usr` - 私たち標準的なユーザーがソフトウェアパッケージをインストールした場合、一般的には `/usr/bin` の場所にインストールされます。
![](Images/Day16_Linux23.png)
- `/var` - Our applications get installed in a `bin` folder. We need somewhere to store all of the log files this is `/var`
- `/var` - 私たちのアプリケーションは `bin` フォルダにインストールされます。すべてのログファイルを保存する場所が必要で、これは `/var` です。
![](Images/Day16_Linux24.png)
## Storage
## ストレージ
When we come to a Linux system or any system we might want to know the available disks and how much free space we have on those disks. The next few commands will help us identify and use and manage storage.
Linux システムやその他のシステムで、利用可能なディスクとそのディスクにある空き容量を知りた い場合があります。次のいくつかのコマンドは、ストレージを識別し、使用し、管理するのに役立ちます。
- `lsblk` List Block devices. `sda` is our physical disk and then `sda1, sda2, sda3` are our partitions on that disk.
- `lsblk` - ブロックデバイスをリストアップします。`sda` は物理ディスク、そして `sda1、sda2、sda3` はそのディスク上のパーティションです。
![](Images/Day16_Linux25.png)
- `df` gives us a little more detail about those partitions, total, used and available. You can parse other flags here I generally use `df -h` to give us a human output of the data.
- `df` - パーティション、合計、使用、使用可能について、もう少し詳しく教えてくれます。他のフラグを指定することもできますが、一般的には `df -h` を使ってデータを人間的に出力しています。
![](Images/Day16_Linux26.png)
If you were adding a new disk to your system and this is the same in Windows you would need to format the disk in disk management, in the Linux terminal you can do this by using the `sudo mkfs -t ext4 /dev/sdb` with sdb relating to our newly added disk.
Linuxのターミナルでは、`sudo mkfs -t ext4 /dev/sdb` を使って、sdbを新しく追加したディスクに関連付けながらフォーマットすることができます。
We would then need to mount our newly formatted disk so that it was useable. We would do this in our `/mnt` folder previously mentioned and we would create a directory there with `sudo mkdir NewDisk` we would then use `sudo mount /dev/sdb newdisk` to mount the disk to that location.
次に、新しくフォーマットしたディスクを使用できるようにマウントする必要があります。これを前述の `/mnt` フォルダに行い、そこに `sudo mkdir NewDisk` でディレクトリを作成し、 `sudo mount /dev/sdb newdisk` でその場所にディスクをマウントします。
It is also possible that you will need to unmount storage from your system safely vs just pulling it from the configuration. We can do this with `sudo umount /dev/sdb`
また、システムからストレージを安全にアンマウントする必要がある場合もあります。これを行うには、`sudo umount /dev/sdb` とします。
If you did not want to unmount that disk and you were going to be using this disk for a database or some other persistent use case then you want it to be there when you reboot your system. For this to happen we need to add this disk to our `/etc/fstab` configuration file for it to persist, if you don't it won't be useable when the machine reboots and you would manually have to go through the above process. The data will still be there on the disk but it won't automount unless you add the configuration to this file.
ディスクをアンマウントせず、このディスクをデータベースやその他の永続的な用途に使用する場合、システムを再起動したときにディスクが存在するようにしたいものです。そのためには、このディスクを `/etc/fstab` 設定ファイルに追加して持続させる必要があります。そうしないと、マシンを再起動したときに使用できなくなり、手動で上記のプロセスを実行しなければならなくなります。データはディスク上に残りますが、このファイルに設定を追加しない限り、オートマウン トは行われません。
Once you have edited the `fstab` configuration file you can check your workings with `sudo mount -a` if no errors then your changes will now be persistent across restarts.
`fstab` 設定ファイルを編集したら、`sudo mount -a` で動作を確認できます。もしエラーがなければ、変更した内容は再起動しても持続します。
We will cover how you would edit a file using a text editor in a future session.
テキストエディタを使ってファイルを編集する方法については、次回のセッションで説明します。
## Resources
## リソース
- [Learn the Linux Fundamentals - Part 1](https://www.youtube.com/watch?v=kPylihJRG70)
- [Linux for hackers (don't worry you don't need to be a hacker!)](https://www.youtube.com/watch?v=VbEx7B_PTOE)
See you on [Day17](day17.md)
[Day17](day17.md)でお会いしましょう。

View File

@ -1,85 +1,85 @@
---
title: '#90DaysOfDevOps - Text Editors - nano vs vim - Day 17'
title: '#90DaysOfDevOps - テキストエディター - nano vs vim - 17日目'
published: false
description: 90DaysOfDevOps - Text Editors - nano vs vim
description: 90DaysOfDevOps - テキストエディター - nano vs vim
tags: "devops, 90daysofdevops, learning"
cover_image: null
canonical_url: null
id: 1048703
---
## Text Editors - nano vs vim
## テキストエディター - nano vs vim
The majority of your Linux systems are going to be servers and these are not going to have a GUI. I also mentioned in the last session that Linux is mostly made up of configuration files, to make changes you are going to need to be able to edit those configuration files to change anything on the system.
Linuxシステムの大半はサーバーであり、GUIを持たないでしょう。前回のセッションで、Linuxはほとんど設定ファイルで構成されており、システム上の何かを変更するためには、設定ファイルを編集できる必要があることを述べました。
There are lots of options out there but I think we should cover probably the two most common terminal text editors. I have used both of these editors and for me, I find `nano` the easy button when it comes to quick changes but `vim` has such a broad set of capabilities.
たくさんのオプションがありますが、おそらく最も一般的な2つのターミナル・テキストエディタをカバーする必要があると思います。私はこの2つのエディタを使ったことがありますが、素早い変更には `nano` が簡単で、`vim` は非常に幅広い機能を持っています。
### nano
- Not available on every system.
- Great for getting started.
- すべてのシステムで利用できるわけではありません。
- 使い始めに最適です。
If you run `nano 90DaysOfDevOps.txt` we will create a new file with nothing in, from here we can add our text and we have our instructions below for what we want to do with that file.
`nano 90DaysOfDevOps.txt` を実行すると、何も入っていない新しいファイルが作成されます。ここからテキストを追加して、そのファイルに対して何をしたいかを以下に説明します。
![](Images/Day17_Linux1.png)
We can now use `control x + enter` and then run `ls` you can now see our new text file.
次に、`control x + enter`を使用して、`ls`を実行すると、新しいテキストファイルが表示されます。
![](Images/Day17_Linux2.png)
We can now run `cat` against that file to read our file. We can then use that same `nano 90DaysOfDevOps.txt` to add additional text or modify your file.
これで、そのファイルに対して `cat` を実行し、ファイルを読み込むことができます。それから同じように `nano 90DaysOfDevOps.txt` を使って、テキストを追加したりファイルを修正したりすることができます。
For me, nano is super easy when it comes to getting small changes done on configuration files.
私にとっては、設定ファイルにちょっとした変更を加えるのに、nanoはとても簡単です。
### vim
Possibly the most common text editor around? A sibling of the UNIX text editor vi from 1976 we get a lot of functionality with vim.
最も一般的なテキストエディタと言えるかもしれません。1976年に発売されたUNIXのテキストエディタviの兄弟で、vimで多くの機能を手に入れることができます。
- Pretty much supported on every single Linux distribution.
- Incredibly powerful! You can likely find a full 7-hour course just covering vim.
- すべてのLinuxディストリビューションでサポートされています。
- 信じられないほど強力です。7時間コースでvimを学ぶことができます。
We can jump into vim with the `vim` command or if we want to edit our new txt file we could run `vim 90DaysOfDevOps.txt` but you are going to first see the lack of help menus at the bottom.
`vim` コマンドで vim に飛び込んだり、新しい txt ファイルを編集したい場合は `vim 90DaysOfDevOps.txt` を実行しますが、まず最初に下の方にあるヘルプメニューがないことに気がつくと思います。
The first question might be "How do I exit vim?" that is going to be `escape` and if we have not made any changes then it will be `:q`
最初の質問は "How do I exit vim?" で、これは `escape` で、もし何も変更していなければ `:q` となります。
![](Images/Day17_Linux3.png)
You start in `normal` mode, there are other modes `command, normal, visual, insert` , if we want to add the text we will need to switch from `normal` to `insert` we need to press `i` if you have added some text and would like to save these changes then you would hit escape and then `:wq`
テキストを追加したい場合は、`normal`から`insert`に切り替える必要があります。テキストを追加して、その変更を保存したい場合は、escapeキーを押して、次に `:wq` を押します。
![](Images/Day17_Linux4.png)
![](Images/Day17_Linux5.png)
You can confirm this with the `cat` command to check you have saved those changes.
この確認は `cat` コマンドで変更内容が保存されているかどうかを確認します。
There is some cool fast functionality with vim that allows you to do menial tasks very quickly if you know the shortcuts which is a lecture in itself. Let's say we have added a list of repeated words and we now need to change that, maybe it's a configuration file and we repeat a network name and now this has changed and we quickly want to change this. I am using the word day for this example.
vim にはクールな高速機能があり、ショートカットを知っていれば、ちょっとした作業を非常に素早く行うことができます。例えば、繰り返される単語のリストを追加して、それを変更する必要があるとします。例えば、設定ファイルで、ネットワーク名を繰り返していますが、これが変更されたので、すぐにこれを変更したいとします。この例では、dayという単語を使っています。
![](Images/Day17_Linux6.png)
Now we want to replace that word with 90DaysOfDevOps, we can do this by hitting `esc` and typing `:%s/Day/90DaysOfDevOps`
この単語を 90DaysOfDevOps に置き換えるには、`esc` を押して `:%s/Day/90DaysOfDevOps` と入力してください。
![](Images/Day17_Linux7.png)
The outcome when you hit enter is that the word day is then replaced with 90DaysOfDevOps.
エンターキーを押すと、dayという単語が90DaysOfDevOpsに置き換わります。
![](Images/Day17_Linux8.png)
Copy and Paste was a big eye-opener for me. Copy is not copy it is yank. we can copy using `yy` on our keyboard in normal mode. `p` paste on the same line, `P` paste on a new line.
コピーペーストは、私にとって大きな目から鱗でした。キーボードの「yy」を使ってコピーすることができます。同じ行に`p`ペースト、新しい行に`p`ペースト。
You can also delete these lines by choosing the number of lines you wish to delete followed by `dd`
また、削除したい行数を選んでから`dd`を押すと、その行を削除することができます。
There is also likely a time you will need to search a file, now we can use `grep` as mentioned in a previous session but we can also use vim. we can use `/word` and this will find the first match, to navigate through to the next you will use the `n` key and so on.
以前のセッションで紹介したように `grep` を使うこともできますが、vim を使うこともできます。
For vim this is not even touching the surface, the biggest advice I can give is to get hands-on and use vim wherever possible.
vimの場合、これは表面的なことにさえ触れていません。私ができる最大のアドバイスは、可能な限り手を動かしてvimを使用することです。
A common interview question is what is your favourite text editor in Linux and I would make sure you have at least this knowledge of both so you can answer, it is fine to say nano because it's simple. At least you show competence in understanding what a text editor is. But get hands-on with them to be more proficient.
よくある面接の質問で、Linuxで好きなテキストエディタは何かというのがありますが、私は少なくともこの2つの知識があることを確認し、答えられるようにします。少なくとも、テキストエディタが何であるかを理解する能力があることを示すことができます。しかし、より熟練するために、それらと手をつないでください。
Another pointer to navigate around in vim we can use `H,J,K,L` as well as our arrow keys.
もう一つのポインターは、vim では矢印キーの他に `H,J,K,L` を使って移動することができます。
## Resources
## リソース
- [Vim in 100 Seconds](https://www.youtube.com/watch?v=-txKSRn0qeA)
- [Vim tutorial](https://www.youtube.com/watch?v=IiwGbcd8S7I)
- [Learn the Linux Fundamentals - Part 1](https://www.youtube.com/watch?v=kPylihJRG70)
- [Linux for hackers (don't worry you don't need to be a hacker!)](https://www.youtube.com/watch?v=VbEx7B_PTOE)
See you on [Day18](day18.md)
[Day18](day18.md)でお会いしましょう。

View File

@ -1,155 +1,159 @@
---
title: '#90DaysOfDevOps - SSH & Web Server - Day 18'
title: '#90DaysOfDevOps - SSHWebサーバー - 18日目'
published: false
description: 90DaysOfDevOps - SSH & Web Server
description: 90DaysOfDevOps - SSHWebサーバー
tags: "devops, 90daysofdevops, learning"
cover_image: null
canonical_url: null
id: 1048733
---
## SSH & Web Server
As we have mentioned throughout you are going to most likely be managing lots of remote Linux servers, because of this, you will need to make sure that your connectivity to these remote servers is secure. In this section, we want to cover some of the basics of SSH that everyone should know that will help you with that secure tunnel to your remote systems.
## SSHWebサーバー
- Setting up a connection with SSH
- Transferring files
- Create your private key
これまで述べてきたように、多くのリモート Linux サーバーを管理することになるので、リモートサーバーへの接続が安全であることを確認する必要があります。このセクションでは、リモートシステムとの安全な接続に役立つ、誰もが知っておくべき SSH の基本をいくつか取り上げます。
### SSH introduction
- SSH による接続のセットアップ
- ファイルの転送
- 秘密鍵の作成
- Secure shell
- Networking Protocol
- Allows secure communications
- Can secure any network service
- Typically used for remote command-line access
### SSH の紹介
In our environment, if you have been following along we have been using SSH already but this was all configured and automated through our vagrant configuration so we only had to run `vagrant ssh` and we gained access to our remote virtual machine.
- セキュアシェル
- ネットワークプロトコル
- 安全な通信を可能にする
- あらゆるネットワークサービスを保護することができる
- 一般的にリモートコマンドラインアクセスに使用される
If our remote machine was not on the same system as our workstation and was in a remote location, maybe a cloud-based system or running in a data centre that we could only access over the internet we would need a secure way of being able to access the system to manage it.
私たちの環境では、すでに SSH を使っていますが、これはすべて vagrant の設定によって自動化されているので、`vagrant ssh` を実行するだけで、リモート仮想マシンにアクセスできるようになります。
SSH provides a secure tunnel between client and server so that nothing can be intercepted by bad actors.
もしリモートマシンがワークステーションと同じシステム上になく、遠隔地にある場合、例えばクラウドベースのシステムであったり、インターネット経由でしかアクセスできないデータセンターで動いている場合、システムを管理するために安全にアクセスする方法が必要です。
SSHはクライアントとサーバーの間に安全なトンネルを提供し、悪意ある者に傍受されることがないようにします。
![](Images/Day18_Linux1.png)
The server has a server-side SSH service always running and listening on a specific TCP port (22).
サーバーにはサーバーサイドのSSHサービスが常に稼働しており、特定のTCPポート(22)でリッスンしています。
If we use our client to connect with the correct credentials or SSH key then we gain access to that server.
クライアントを使って正しい認証情報またはSSHキーで接続すれば、そのサーバーにアクセスすることができます。
### Adding a bridged network adapter to our system
### ブリッジネットワークアダプターをシステムに追加する
In order for us to use this with our current virtual box VM, we need to add a bridged network adapter to our machine.
現在の仮想マシンでこの機能を使用するには、ブリッジドネットワークアダプターをマシンに追加する必要があります。
Power down your virtual machine, right-click on your machine within Virtual Box and select settings. In the new window then select networking.
仮想マシンをパワーダウンし、Virtual Box内でマシンを右クリックし、[設定]を選択します。新しいウィンドウが表示されたら、[ネットワーク]を選択します。
![](Images/Day18_Linux2.png)
Now power your machine back on and you will now have an IP address on your local machine. You can confirm this with the `ip addr` command.
マシンの電源を入れ直すと、ローカルマシンにIPアドレスが設定されているはずです。ip addr`コマンドで確認することができます。
### Confirming SSH server is running
### SSHサーバーが起動していることを確認する
We know SSH is already configured on our machine as we have been using it with vagrant but we can confirm by running
SSHはvagrantで使っているのですでに設定されているはずですが、次のコマンドで確認できます。
`sudo systemctl status ssh`
sudo systemctl status ssh` を実行して確認します。
![](Images/Day18_Linux3.png)
If your system does not have the SSH server then you can install it by issuing this command `sudo apt install openssh-server`
SSH サーバーがない場合は、`sudo apt install openssh-server` というコマンドでインストールすることができます。
You then want to make sure that our SSH is allowed if the firewall is running. We can do this with `sudo ufw allow ssh` this is not required on our configuration as we automated this with our vagrant provisioning.
次に、ファイアウォールが動作している場合に、SSHが許可されることを確認します。これは `sudo ufw allow ssh` で行えますが、Vagrant のプロビジョニングで自動化されているので、この設定には必要ありません。
### Remote Access - SSH Password
### リモートアクセス - SSHパスワード
Now that we have our SSH Server listening out on port 22 for any incoming connection requests and we have added the bridged networking we could use putty or an SSH client on our local machine to connect into our system using SSH.
SSHサーバーがポート22をリッスンし、ブリッジネットワークが追加されたので、ローカルマシンでputtyまたはSSHクライアントを使用してSSHを使用してシステムに接続することができるようになりました。
![](Images/Day18_Linux4.png)
Then hit open, if this is the first time you have connected to this system via this IP address you will get this warning. We know that this is our system so you can choose yes.
もし、このIPアドレスでこのシステムに接続するのが初めてなら、この警告が表示されます。私たちのシステムであることがわかりますので、「はい」を選択してください。
![](Images/Day18_Linux5.png)
We are then prompted for our username (vagrant) and password (default password - vagrant) Below you will see we are now using our SSH client (Putty) to connect to our machine using username and password.
ユーザー名(vagrant)とパスワード(デフォルトパスワード - vagrant)の入力を要求されます。
![](Images/Day18_Linux6.png)
At this stage, we are connected to our VM from our remote client and we can issue our commands on our system.
この段階で、リモートクライアントからVMに接続され、システム上でコマンドを発行することができます。
### Remote Access - SSH Key
### リモートアクセス - SSHキー
The above is an easy way to gain access to your systems however it still relies on username and password, if some malicious actor was to gain access to this information plus the public address or IP of your system then it could be easily compromised. This is where SSH keys are preferred.
上記の方法は、システムにアクセスする簡単な方法ですが、ユーザー名とパスワードに依存しているため、悪意のある俳優がこの情報とシステムのパブリックアドレスまたはIPにアクセスした場合、簡単に危険にさらされる可能性があります。そこで、SSH鍵の使用が推奨されます。
SSH Keys means that we provide a key pair so that both the client and server know that this is a trusted device.
SSHキーとは、クライアントとサーバーの両方が信頼できるデバイスであることを認識できるように、キーペアを提供することを意味します。
Creating a key is easy. On our local machine (Windows) We can issue the following command in fact if you have an ssh-client installed on any system I believe this same command will work?
鍵の作成は簡単です。私たちのローカルマシン(Windows)では、次のコマンドを発行できます。実際、どのシステムにもsshクライアントがインストールされていれば、これと同じコマンドが使えると思います。
`ssh-keygen -t ed25519`
ssh-keygen -t ed25519` とします。
I am not going to get into what `ed25519` is and means here but you can have a search if you want to learn more about [cryptography](https://en.wikipedia.org/wiki/EdDSA#Ed25519)
ed25519`が何なのか、どういう意味なのかはここでは触れませんが、[暗号](https://en.wikipedia.org/wiki/EdDSA#Ed25519)についてもっと知りたければ検索してみてください。
![](Images/Day18_Linux7.png)
At this point we have our created SSH key stored in `C:\Users\micha/.ssh/`
この時点で、作成したSSH鍵は `C:\Usersersmicha/.ssh/` に保存されています。
But in order to link this with our Linux VM we need to copy the key. We can do this by using the `ssh-copy-id vagrant@192.168.169.135`
しかし、これをLinux VMとリンクさせるためには、鍵をコピーする必要があります。これは `ssh-copy-id vagrant@192.168.169.135` を使って行うことができます。
I used Powershell to create my keys on my Windows client but there is no `ssh-copy-id` available here. There are ways in which you can do this on Windows and a small search online will find you an alternative, but I will just use git bash on my Windows machine to make the copy.
Windowsクライアントで鍵を作成するのにPowershellを使いましたが、こちらでは`ssh-copy-id`が使えません。Windowsでこれを行う方法はありますし、ネットでちょっと検索すれば代替案が見つかると思いますが、ここではWindowsマシンでgit bashを使ってコピーを作成することにします。
![](Images/Day18_Linux8.png)
We can now go back to Powershell to test that our connection now works with our SSH Keys and no password is required.
Powershellに戻り、SSHキーで接続し、パスワードが不要であることをテストします。
`ssh vagrant@192.168.169.135`
![](Images/Day18_Linux9.png)
We could secure this further if needed by using a passphrase. We could also go one step further saying that no passwords at all meaning only key pairs over SSH would be allowed. You can make this happen in the following configuration file.
必要であれば、パスフレーズを使用することで、さらにセキュリティを高めることができます。さらに一歩進んで、パスワードは一切不要、つまりSSH経由のキーペアのみが許可されるようにすることも可能です。これは次の設定ファイルで実現できます。
`sudo nano /etc/ssh/sshd_config`
`sudo nano /etc/ssh/sshd_config` とします。
there is a line in here with `PasswordAuthentication yes` this will be `#` commented out, you should uncomment and change the yes to no. You will then need to reload the SSH service with `sudo systemctl reload sshd`
この中に `PasswordAuthentication yes` という行がありますが、これは `#` でコメントアウトされているので、コメントを解除して yes を no に変更する必要があります。それから SSH サービスを `sudo systemctl reload sshd` で再読み込みする必要があります。
## Setting up a Web Server
## ウェブサーバのセットアップ
Not specifically related to what we have just done with SSH above but I wanted to include this as this is again another task that you might find a little daunting but it really should not be.
上の SSH の話とは特に関係ないのですが、これもまた少し大変な作業だと思うかもしれませんが、そうではありません。
We have our Linux playground VM and at this stage, we want to add an apache webserver to our VM so that we can host a simple website from it that serves out to my home network. Note that this web page will not be accessible from the internet, this can be done but it will not be covered here.
Linux プレイグラウンド VM ができましたので、この段階で、apache ウェブサーバを VM に追加して、ホームネットワークに公開する簡単なウェブサイトをホストできるようにしたいと思います。この Web ページはインターネットからアクセスできないことに注意してください。
You might also see this referred to as a LAMP stack.
また、LAMPスタックと呼ばれることもあります。
- **L**inux Operating System
- **A**pache Web Server
- **m**ySQL database
- **L**inuxオペレーティングシステム
- **A**pache ウェブサーバー
- **M**ySQLデータベース
- **P**HP
### Apache2
Apache2 is an open-source HTTP server. We can install apache2 with the following command.
`sudo apt-get install apache2`
Apache2は、オープンソースのHTTPサーバーです。以下のコマンドでapache2をインストールすることができます。
To confirm that apache2 is installed correctly we can run `sudo service apache2 restart`
`sudo apt-get install apache2` です。
Then using the bridged network address from the SSH walkthrough open a browser and go to that address. Mine was `http://192.168.169.135/`
apache2が正しくインストールされたことを確認するために、`sudo service apache2 restart`を実行します。
次に、SSHチュートリアルのブリッジされたネットワークアドレスを使って、ブラウザを開き、そのアドレスにアクセスします。私のは `http://192.168.169.135/` でした。
![](Images/Day18_Linux10.png)
### mySQL
MySQL is a database in which we will be storing our data for our simple website. To get MySQL installed we should use the following command `sudo apt-get install mysql-server`
### MySQL
MySQLは、私たちの簡単なウェブサイトのデータを格納するためのデータベースです。MySQLをインストールするには、次のコマンドを使用します `sudo apt-get install mysql-server`.
### PHP
PHP is a server-side scripting language, we will use this to interact with a MySQL database. The final installation is to get PHP and dependencies installed using `sudo apt-get install php libapache2-mod-php php-mysql`
The first configuration change we want to make it out of the box apache is using index.html and we want it to use index.php instead.
PHPはサーバーサイドのスクリプト言語で、MySQLデータベースとのやりとりに使用します。最終的には、`sudo apt-get install php libapache2-mod-php php-mysql` を使って PHP と依存関係をインストールすることになります。
We are going to use `sudo nano /etc/apache2/mods-enabled/dir.conf` and we are going to move index.php to the first item in the list.
最初の設定変更は、apacheがindex.htmlを使っているので、index.phpを使うようにすることです。
sudo nano /etc/apache2/mods-enabled/dir.conf` を使って、index.phpをリストの最初のアイテムに移動します。
![](Images/Day18_Linux11.png)
Restart the apache2 service `sudo systemctl restart apache2`
apache2 サービスを再起動する `sudo systemctl restart apache2`
Now let's confirm that our system is configured correctly for PHP. Create the following file using this command, this will open a blank file in nano.
ここで、PHPが正しく設定されていることを確認しましょう。次のコマンドを使用して、次のファイルを作成します。これは、nano で空のファイルを開きます。
`sudo nano /var/www/html/90Days.php`
`sudo nano /var/www/html/90Days.php` を作成します。
then copy the following and use control + x to exit and save your file.
をコピーし、control + x で終了し、ファイルを保存します。
```
<?php
@ -157,13 +161,13 @@ phpinfo();
?>
```
Now navigate to your Linux VM IP again with the additional 90Days.php on the end of the URL. `http://192.168.169.135/90Days.php` you should see something similar to the below if PHP is configured correctly.
90Days.php を URL の末尾に追加して、Linux VM の IP アドレスに再度アクセスします。http://192.168.169.135/90Days.php` PHPが正しく設定されていれば、以下のような表示になるはずです。
![](Images/Day18_Linux12.png)
### WordPress Installation
### WordPress のインストール
I then walked through this tutorial to get WordPress up on our LAMP stack, some commands are shown below if not shown correctly in the walkthrough [How to install wordpress on Ubuntu with LAMP](https://blog.ssdnodes.com/blog/how-to-install-wordpress-on-ubuntu-18-04-with-lamp-tutorial/)
このチュートリアルを参考に、LAMP環境下でWordPressをインストールしました。「How to install wordpress on Ubuntu with LAMP」(https://blog.ssdnodes.com/blog/how-to-install-wordpress-on-ubuntu-18-04-with-lamp-tutorial/) に記載されていないコマンドを以下に示します。
`sudo mysql -u root -p`
@ -190,13 +194,13 @@ I then walked through this tutorial to get WordPress up on our LAMP stack, some
`sudo rm latest.tar.gz`
At this point you are Step 4 in the linked article, you will need to follow the steps to make sure all correct permissions are in place for the WordPress directory.
この時点では、リンク先の記事のステップ4です。ステップに従って、WordPressディレクトリに正しいパーミッションがすべて設定されていることを確認する必要があります。
Because this is internal only you do not need to "generate security keys" in this step. Move to Step 5 which is changing the Apache configuration to WordPress.
これは内部的なものなので、このステップでは「セキュリティ・キーの生成」は必要ありません。ステップ5に進み、Apacheの設定をWordPressに変更します。
Then providing everything is configured correctly you will be able to access via your internal network address and run through the WordPress installation.
あとは、内部ネットワークアドレスでアクセスし、WordPressのインストールを実行します。
## Resources
## リソース
- [Client SSH GUI - Remmina](https://remmina.org/)
- [The Beginner's guide to SSH](https://www.youtube.com/watch?v=2QXkrLVsRmk)
@ -205,4 +209,4 @@ Then providing everything is configured correctly you will be able to access via
- [Learn the Linux Fundamentals - Part 1](https://www.youtube.com/watch?v=kPylihJRG70)
- [Linux for hackers (don't worry you don't need to be a hacker!)](https://www.youtube.com/watch?v=VbEx7B_PTOE)
See you on [Day19](day19.md)
[Day19](day19.md)でお会いしましょう。

View File

@ -1,95 +1,97 @@
---
title: '#90DaysOfDevOps - Dev workstation setup - All the pretty things - Day 20'
title: '#90DaysOfDevOps - 開発用ワークステーションのセットアップ - きれいなものばかり - 20日目'
published: false
description: 90DaysOfDevOps - Dev workstation setup - All the pretty things
description: 90DaysOfDevOps - 開発用ワークステーションのセットアップ - きれいなものばかり
tags: "devops, 90daysofdevops, learning"
cover_image: null
canonical_url: null
id: 1048734
---
## Dev workstation setup - All the pretty things
## 開発用ワークステーションのセットアップ - きれいなものばかり
Not to be confused with us setting Linux servers up this way but I wanted to also show off the choice and flexibility that we have within the Linux desktop.
Linuxサーバをこのように設定するのと混同しないように、私はLinuxデスクトップが持つ選択肢と柔軟性を見せたいと思ったんだ。
I have been using a Linux Desktop for almost a year now and I have it configured just the way I want from a look and feel perspective. Using our Ubuntu VM on Virtual Box we can run through some of the customisations I have made to my daily driver.
私は、Linuxデスクトップを1年近く使っていますが、見た目も使い勝手も思い通りに設定できています。Virtual Box上のUbuntu VMを使って、私が日常的に使っているPCに施したカスタマイズのいくつかを紹介します。
I have put together a YouTube video walking through the rest as some people might be able to better follow along:
YouTubeのビデオに残りの部分をまとめましたので、もっとよく理解できるかもしれません。
[![Click to access YouTube Video](Images/Day20_YouTube.png)](https://youtu.be/jeEslAtHfKc)
Out of the box our system will look something like the below:
このシステムには、以下のようなものがあります。
![](Images/Day20_Linux1.png)
We can also see our default bash shell below,
また、以下にデフォルトのbashシェルが表示されます。
![](Images/Day20_Linux2.png)
A lot of this comes down to dotfiles something we will cover in this final Linux session of the series.
このシリーズの最後のLinuxセッションで取り上げるdotfilesに起因するものが多いのです。
### dotfiles
First up I want to dig into dotfiles, I have said in a previous day that Linux is made up of configuration files. These dotfiles are configuration files for your Linux system and applications.
I will also add that dotfiles are not just used to customise and make your desktop look pretty, there are also dotfile changes and configurations that will help you with productivity.
まず最初に、ドットファイルについて掘り下げたいと思います。Linuxは設定ファイルでできていると前日に述べました。このドットファイルはLinuxのシステムやアプリケーションの設定ファイルです。
As I mentioned many software programs store their configurations in these dotfiles. These dotfiles assist in managing functionality.
また、ドットファイルは単にデスクトップのカスタマイズや見栄えを良くするためだけに使われるのではなく、生産性を高めるために役立つドットファイルの変更や設定もあることを付け加えます。
Each dotfile starts with a `.` You can probably guess where the naming came from?
先に述べたように、多くのソフトウェアプログラムは、その設定をこのドットファイルに保存しています。これらのドットファイルは機能管理を支援するものです。
So far we have been using bash as our shell which means you will have a .bashrc and .bash_profile in our home folder. You can see below a few dotfiles we have on our system.
各ドットファイルは `.` で始まります。この命名の由来はおわかりになるでしょうか。
今までのところ、シェルとしてbashを使っているので、ホームフォルダに.bashrcと.bash_profileがあるはずです。以下に、私たちのシステム上にあるいくつかのドットファイルを示します。
![](Images/Day20_Linux3.png)
We are going to be changing our shell, so we will later be seeing a new `.zshrc` configuration dotfile.
これからシェルを変更するので、後で新しい `.zshrc` 設定ドットファイルを見ることになります。
But now you know if we refer to dotfiles you know they are configuration files. We can use them to add aliases to our command prompt as well as paths to different locations. Some people publish their dotfiles so they are publicly available. You will find mine here on my GitHub [MichaelCade/dotfiles](https://github.com/MichaelCade/dotfiles) here you will find my custom `.zshrc` file, my terminal of choice is terminator which also has some configuration files in the folder and then also some background options.
しかし、これでドットファイルを参照する場合、それが設定ファイルであることがわかるでしょう。ドットファイルを使って、コマンドプロンプトにエイリアスを追加したり、別の場所へのパスを追加したりすることができます。ドットファイルを公開している人もいます。私のものは私のGitHub [MichaelCade/dotfiles](https://github.com/MichaelCade/dotfiles) にあります。ここには私のカスタム `.zshrc` ファイルがあり、私が選んだターミナルは terminator で、そのフォルダにはいくつかの設定ファイルと、背景オプションも入っています。
### ZSH
As I mentioned throughout our interactions so far we have been using a bash shell the default shell with Ubuntu. ZSH is very similar but it does have some benefits over bash.
Zsh has features like interactive Tab completion, automated file searching, regex integration, advanced shorthand for defining command scope, and a rich theme engine.
これまで述べてきたように、私たちはUbuntuのデフォルトシェルであるbashシェルを使ってきました。ZSH は非常によく似ていますが、bash よりも優れている点がいくつかあります。
We can use our `apt` package manager to get zsh installed on our system. Let's go ahead and run `sudo apt install zsh` from our bash terminal. I am going to do this from within the VM console vs being connected over SSH.
Zsh は対話的なタブ補完、自動ファイル検索、正規表現の統合、コマンドスコープを定義するための高度な省略記法、豊富なテーマエンジンなどの機能を備えています。
When the installation command is complete you can run `zsh` inside your terminal, this will then start a shell configuration script.
私たちのシステムに zsh をインストールするには、`apt` パッケージマネージャを使 用します。bashターミナルから `sudo apt install zsh` を実行してみましょう。SSH で接続している場合ではなく、VM コンソールから実行するつもりです。
インストールが完了したら、ターミナルで `zsh` を実行すると、シェルの設定スクリプトが起動します。
![](Images/Day20_Linux4.png)
I selected `1` to the above question and now we have some more options.
上の質問で`1`を選択したところ、さらにいくつかの選択肢ができました。
![](Images/Day20_Linux5.png)
You can see from this menu you we can make some out of the box edits to make ZSH configured to our needs.
このメニューから、ZSH を私たちのニーズに合わせて設定するために、いくつかの編集を行うことができることがわかるでしょう。
If you exit the wizard with a `0` and then use the `ls -al | grep .zshrc` you should see we have a new configuration file.
`0` でウィザードを終了し、`ls -al | grep .zshrc` を実行すると、新しい設定ファイルができているのがわかると思います。
Now we want to make zsh our default shell every time we open our terminal, we can do this by running the following command to change our shell `chsh -s $(which zsh)` we then need to log out and back in again for the changes to take place.
ここで、ターミナルを開くたびに zsh をデフォルトのシェルにしたいと思います。これを行うには、次のコマンドを実行してシェルを変更します `chsh -s $(which zsh)` その後、ログアウトして変更を反映させるために再びログインする必要があります。
When you log back and open a terminal it should look something like this. We can also confirm our shell has now been changed over by running `which $SHELL`
ログアウトしてターミナルを開くと、このような状態になっているはずです。また、`which $SHELL` を実行することで、シェルが変更されたことを確認することができます。
![](Images/Day20_Linux6.png)
I generally perform this step on each Ubuntu desktop I spin up and find in general without going any further that the zsh shell is a little faster than bash.
私は通常、スピンアップする各Ubuntuデスクトップ上でこのステップを実行し、それ以上のことをしなくても、一般的にzshシェルはbashよりも少し速いことがわかります。
### OhMyZSH
Next up we want to make things look a little better and also add some functionality to help us move around within the terminal.
次はもう少し見栄えを良くして、ターミナル内の移動を助ける機能を追加したいと思います。
OhMyZSH is a free and open source framework for managing your zsh configuration. There are lots of plugins, themes and other things that just make interacting with the zsh shell a lot nicer.
OhMyZSH は zsh の設定を管理するためのフリーでオープンソースのフレームワークです。たくさんのプラグインやテーマ、その他のものがあり、zsh シェルとのやりとりをより快適にしてくれます。
You can find out more about [ohmyzsh](https://ohmyz.sh/)
ohmyzsh](https://ohmyz.sh/)についてもっと知ることができます。
Let's get Oh My ZSH installed, we have a few options with `curl` `wget` or `fetch` we have the first two available on our system but I will lead with `curl`
Oh My ZSHをインストールしましょう。`curl` `wget``fetch` などのオプションがありますが、私たちのシステムでは最初の2つが利用可能です。
`sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"`
When you have run the above command you should see some output like below.
上記のコマンドを実行すると、以下のような出力が表示されるはずです。
![](Images/Day20_Linux7.png)
Now we can move on to start putting a theme in for our experience, there are well over 100 bundled with Oh My ZSH but my go to for all of my applications and everything is the dracula theme.
Oh My ZSHには100以上のテーマが同梱されていますが、私が一番よく使うのはドラキュラのテーマです。
I also want to add that these two plugins are a must when using Oh My ZSH.
また、Oh My ZSHを使用する際には、この2つのプラグインは必須であることを付け加えておきます。
`git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions`
@ -97,11 +99,11 @@ When you have run the above command you should see some output like below.
`nano ~/.zshrc`
edit the plugins to now include `plugins=(git zsh-autosuggestions zsh-syntax-highlighting)`
プラグインを編集して、`plugins=(git zsh-autosuggestions zsh-syntax-highlighting)` を含めるようにします。
## Gnome Extensions
## Gnome 拡張
I also use Gnome extensions, and in particular the list below
また、Gnomeの拡張機能を使用しており、特に以下のリストを参考にしています。
[Gnome extensions](https://extensions.gnome.org)
@ -111,9 +113,9 @@ I also use Gnome extensions, and in particular the list below
- Desktop Icons
- User Themes
## Software Installation
## ソフトウェアのインストール
A short list of the programs I install on the machine using `apt`
私が `apt` を使ってマシンにインストールしているプログラムの短いリストです。
- VSCode
- azure-cli
@ -127,27 +129,27 @@ A short list of the programs I install on the machine using `apt`
- terraform
- vagrant
### Dracula theme
### Dracula テーマ
This site is the only theme I am using at the moment. Looks clear, clean and everything looks great. [Dracula Theme](https://draculatheme.com/) It also has you covered when you have lots of other programs you use on your machine.
このサイトは、私が今使っている唯一のテーマです。見た目もスッキリしていて、全てが素晴らしく見えます。[ドラクエのテーマ](https://draculatheme.com/) また、あなたのマシンで使用する他のプログラムをたくさん持っている場合にも、このサイトでカバーされています。
From the link above we can search for zsh on the site and you will find at least two options.
上記のリンクから、サイト上でzshを検索すると、少なくとも2つのオプションが見つかります。
Follow the instructions listed to insall either manually or using git. Then you will need to finally edit your `.zshrc` configuration file as per below.
記載されている手順に従って、手動または git を使ってインストールします。そして、最後に `.zshrc` 設定ファイルを以下のように編集する必要があります。
![](Images/Day20_Linux8.png)
You are next going to want the [Gnome Terminal Dracula theme](https://draculatheme.com/gnome-terminal) with all instructions available here as well.
次に、[Gnome Terminal Dracula theme](https://draculatheme.com/gnome-terminal)が必要です。すべての手順はここで入手できます。
It would actually take a long time for me to document each and every step so I created a video walkthrough of the process. (**Click on the image below**)
一つ一つの手順を記録するのは時間がかかるので、ビデオで手順を説明します。(**下の画像をクリックしてください**)
[![](Images/Day20_YouTube.png)](https://youtu.be/jeEslAtHfKc)
[!](Images/Day20_YouTube.png)](https://youtu.be/jeEslAtHfKc)
If you made it this far, then we have now finished our Linux section of the #90DaysOfDevOps. Once again I am open for feedback and additions to resources here.
ここまで来れば、#90DaysOfDevOpsのLinuxセクションは終了です。今回もまた、フィードバックやリソースの追加をお待ちしています。
I also thought on this it was easier to show you a lot of the steps through video vs writing them down here, what do you think to this? I do have a goal to work back through these days and where possible creating video walkthroughs to add in and better maybe explain and show some of the things we have covered. What do you think?
また、今回、多くのステップをビデオで紹介する方が、ここに書き出すよりも簡単だと思ったのですが、いかがでしょうか?私は、これらの日々を振り返って、可能であればビデオ・ウォークスルーを作成して、私たちがカバーした事柄のいくつかをより良く説明し、示すという目標を持っています。いかがでしょうか?
## Resources
## リソース
- [Bash in 100 seconds](https://www.youtube.com/watch?v=I4EWvMFj37g)
- [Bash script with practical examples - Full Course](https://www.youtube.com/watch?v=TPRSJbtfK4M)
@ -158,6 +160,6 @@ I also thought on this it was easier to show you a lot of the steps through vide
- [Learn the Linux Fundamentals - Part 1](https://www.youtube.com/watch?v=kPylihJRG70)
- [Linux for hackers (don't worry you don't need to be a hacker!)](https://www.youtube.com/watch?v=VbEx7B_PTOE)
Tomorrow we start our 7 days of diving into Networking, we will be looking to give ourselves the foundational knowledge and understanding of Networking around DevOps.
明日から7日間、ネットワークに潜り込み、DevOpsを中心としたネットワークの基礎知識と理解を深めたいと思います。
See you on [Day21](day21.md)
それでは [Day21] (day21.md) でお会いしましょう。

View File

@ -38,13 +38,13 @@ English Version | [中文版本](zh_cn/README.md) | [繁體中文版本](zh_tw/R
### Knowing Linux Basics
- [✔️] 🐧 14 > [The Big Picture: DevOps and Linux](Days/day14.md)
- [✔️] 🐧 15 > [Linux Commands for DevOps (Actually everyone)](Days/day15.md)
- [✔️] 🐧 16 > [Managing your Linux System, Filesystem & Storage](Days/day16.md)
- [✔️] 🐧 17 > [Text Editors - nano vs vim](Days/day17.md)
- [✔️] 🐧 18 > [SSH & Web Server(LAMP)](Days/day18.md)
- [✔️] 🐧 19 > [Automate tasks with bash scripts](Days/day19.md)
- [✔️] 🐧 20 > [Dev workstation setup - All the pretty things](Days/day20.md)
- [✔️] 🐧 14 > [全体像の把握 DevOpsとLinux](Days/day14.md)
- [✔️] 🐧 15 > [DevOpsのためのLinuxコマンド](Days/day15.md)
- [✔️] 🐧 16 > [Linuxシステム、ファイルシステム、ストレージの管理](Days/day16.md)
- [✔️] 🐧 17 > [テキストエディター - nano vs vim](Days/day17.md)
- [✔️] 🐧 18 > [SSHWebサーバー](Days/day18.md)
- [✔️] 🐧 19 > [bashスクリプトによるタスクの自動化](Days/day19.md)
- [✔️] 🐧 20 > [開発用ワークステーションのセットアップ - きれいなものばかり](Days/day20.md)
### Understand Networking