File copy (1) -File copy in Raspberry Pi
This is a copy of the file.I plan to move and delete files after copying.However, you may think that you do not want to perform processing such as moving and deleting files in the environment you are using now.It would be hard if you failed in the production environment and deleted important files.In the case of a somewhat dangerous command, it is appropriate to prepare an environment that can be returned immediately even if the problem occurs, or that there is no problem even if it is broken.
So this time, I will use a small, cheap, and a raspberry pie that can be redone as many times as many times.I just thought it would be better to move it on a real machine instead of a virtual environment, so if you are fine with a virtual environment, prepare an environment where you can use Docker to run commands and learn.In fact, it may have been better to write in the first time that it is one of the ways to prepare a virtual environment for learning.Also, this time I use raspberry pie, but in that case it is best if there are three SD cards.One of them may have a small capacity.It is only used as a copy of the copy.
Selection of raspberry pie
Raspberry pie can be used not only for command test but also for IoT and electronic work.The OS provided as standard is also available to use the GUI, and I think it may be gentle for those who first touch such devices (single board computers).(Some are without GUI)
There are several types of raspberry pie, and the latest is Raspberry Pai 4.However, learning and many use of commands will not require the power of raspberry pie 4.So, here we use the previous raspberry pie 3b+.Raspberry Pi2 is fine if you can be late.
Raspberry pie does not work only on the main unit.It is not integrated like a laptop.This requires a display, monitor, keyboard, mouse, Micro USB cable for power supply, and micro SD card.The keyboard and mouse are USB Type A, so you can use them for personal computers as they are.The display is fine if there is something that can be connected to HDMI.It can also be used on home TV.
Micro SD cards must be used depending on the application, but 8GB is enough for learning like this time.If possible, the high -speed transfer speed is better.In addition, purchase at least two SD cards.This is because if you fail to delete a file, you can restore it from another SD card.If it is a application that cannot be stopped because it is not a learning use, it is best to prepare three instead of two.
After preparing the device for the time being, connect other than the power supply.Since the raspberry pie does not have a power switch, the power is turned on as soon as the power is connected (Micro USB cable).Please note that if you remove it, the power will turn off immediately.
Installing raspberry pie OS
Raspberry pie can install various OS simply by replacing the SD card.There are a variety of classic Ubuntu, music use, and robot control.
Here, we use the OS prepared by the Raspberry Pai Foundation.It used to be Rasbian, but now it has been changed to the Raspberry Pi OS.
At the same time as the name has changed to the raspberry pie OS, the method of writing the OS on the SD card has become extremely easy.In the past, I entered commands (though it would be a study).
Now, let's write the raspberry pie OS to the SD card.First, download the raspberry pie OS from the following site.This time, it is a learning use, so use a set (Raspberry Pi OS with Desktop and Recommended Software).
Next, download the software (Raspberry Pi Imager) to write the OS.
After downloading, install (or copy) on the OS after thawing (after deployment).Start Raspberry Pi Imager.
Insert the SD card into the card reader.
Select the OS to write.This time we use Raspberry Pi OS (32-bit).
Select the SD card.
Press the Write button.
The contents of the SD card will be deleted all, so the confirmation dialog will be displayed.Select Yes to start writing.
All you have to do is wait.How long you should wait depends on the speed of reading and writing cards.If you have a slow card, wait patiently.
When the writing is completed, the following dialog is displayed. Click the Continue button.
After writing, remove the SD card and insert it into the raspberry pie.After that, connect the HDMI cable, mouse and keyboard.Also, insert an Ethernet cable if necessary.It is not necessary to connect to a network with wifi.
If you insert it, insert a micro USB cable to supply the power and start it.Starting will take a little time, so wait.
Raspberry pie OS settings
When it starts, follow the procedure.The setting contents and procedures may differ slightly depending on the version of the Raspberry Pi OS, but it is enough to make a basic setting.The 2021-1-11 release version is as follows.When you start, the dialog as shown in the figure is displayed. Click the Next button.
When you set Country to Japan, others are set automatically.If you want to use US KEYBOARD here, check the USE US Keyboard.After setting, click the Next button.
Then enter the password.In this state, the account name is Pi, so you will need to enter the password for this account.If you connect with VNC later, the password will be entered here with the username PI.In the past, it was a password called Raspberry by default, but now it is now set properly.
Next, click the Next button as it is.
If you connect to the network with Wi-Fi, select the connection destination and click the Next button.
Enter the Wi-Fi password to connect.After entering, click the Next button.
Decide whether to update the software.If you do not update, click the SKIP button.Click the Next button to start the update.
When the update is completed, the dialog like the figure is displayed. Click the OK button.
Finally restart.Click the Restart button.After that, wait for the restart.
無事に起動したら終わりです。が、SSHやVNCを使って接続する場合はもう少し設定が必要です。メニューから設定>Raspberry Piの設定を選択します。
Click the SSH and VNC's valid radio button on the interface tab.
Click the V2 icon at the top right of the menu bar to confirm the IP address when connecting with VNC.Then the window as shown in the figure is displayed.
Create SD card duplication
When the setting is over, make a duplication of the SD card.If you make a duplication, you can revive it just by replacing the card even if it fails.Connect the card reader and put the SD card to duplicate there.
If you put an SD card, the dialog as shown in the figure may be displayed.Click the cancellation button here.There is no problem if you click the OK button by mistake, so please continue the following work as it is.
次にディスクコピーのソフトを起動します。メニューのアクセサリ>SD Card Copierを選択します。
Select the duplication source and duplicate destination.Click the Start button.
The confirmation dialog is displayed. Click the Yes button.
The duplication of the SD card starts.
When the duplication is completed, the dialog like the figure is displayed. Click the OK button.If the SD card may not be duplicated, try using a new SD card.When the duplication is over, insert the duplicated card and check if it will start.If you start safely, you are ready.
Connect with VNC
Let's make it possible to connect from the computer venc from the computer.The raspberry pie side has already been set, so set the computer side.Here, I used the following VNC Viewer.VNC Viewer is also for smartphones and tablets.
RealVNChttps://www.realvnc.com/VNC Viewerhttps://www.realvnc.com/en/connect/download/viewer/This time, I used the following version.
When you start VNC Viewer, click the right button in the blank part of the figure and display it from the menu displayed....Choose.By the way, in the case of an Android device, the (+) button is displayed, so click the button.
The setting screen is displayed. Enter the IP address of the raspberry pie to connect to the VNC Server part.The name column is the name to determine the connection destination yourself.You should have an easy -to -understand name.Other parts do not need to be particularly set with the default.After setting, click the OK button.
The connecting destination confirmation dialog is displayed. Click the Continue button.
Enter the username and password of the raspberry pie at the connection destination.The username will be PI.Enter the first password in the raspberry pie.(In the past, Raspberry was the default, but it is now a password that I set myself)
When the setting is completed, the icon (if you connect it once will become a thumbnail), double -click.
When connected safely, the raspberry pie screen will be displayed.The rest is that you can operate it with GUI, so you can freely.
Copy the file
Let's copy the file first.If there is no precautionary note, it will also work in UNIX -based shell environments such as Windows, Mac, Ubuntu.Using raspberry pie is for those who do not want to fail in the production environment, and those who are not used to commands.No problem in the production environment!You can enter the command as it is and have it executed.
First, prepare the file to copy.Create one text file using Echo and redirect.Pi to the desktop to make it easier to understand as usual.Create under the name TXT.
The raspberry pie terminal was explained in the first time, but it starts up as shown in the figure.
When it starts, enter the command as follows.
echo 3.1415 > ~/Desktop/pi.txt
Now, copy this file.314 on the desktop to make it easier to understand.Copy with a file name TXT.Use the CP command to copy the file.Enter as follows.
cp ~/Desktop/pi.txt ~/Desktop/314.txt
Open the copied file with a text editor or use the CAT command to check the contents.Certainly the content is copied.
By the way, in the case of PowerShell, you can copy the file in the same way.This is because the CP is an alias of Copy-ITEM.The same result is made in Poweshell as follows.
Copy-Item ~/Desktop/pi.txt ~/Desktop/314.txt
Next, copy multiple files...I thought it was long, so the next one.
著者 仲村次郎