Raspberry Pi はIoT研究によく使われる機材。
Raspberry Pi の内部はLinux 動く、遠隔管理するため、LinuxのCUIで管理を行う。
$ ssh user1@ip
$ passed user1
- 8 Advanced Optionsを選択
- A4 SSHを選択
$ cd /boot
$ sudo touch ssh
$ sudo reboot
Terminal for Beginners Glossary
One of the great things about Linux is the terminal application. While it may look unfriendly and terse, if you want to really extend the capabilities of CHIP, you’ll often find yourself in the terminal. If you’re a beginner, here’s a quick reference of some really important and common commands. You can simply add
-h to get some hints on how to use a command, such as
cp -h or you can read a manual page using
man cp. Most unix commands have a variety of options that can be executed in the command with flags, such as
ls -l -a. Even better, search the internet! This primer is simply here to help you understand what a command might be doing, not to help you use it to its full ability.
- cd change directory. open a folder. ex:
cd ~/Pictures changes your current directory to the home Pictures folder, so you can easily access the files within.
- mkdir make directory. create a folder. ex:
mkdir Vacation makes a folder named Vacation in the current directory.
mkdir ~/Pictures/Vacationmakes a
Vacation folder in the home Pictures directory.
- ls list files in the current directory so you know what is in it. Some options are
ls -l to list in long format to provide information about permissions, size, and date.
ls -a to show hidden files that start with the
- mv move a file from one directory to another, or to give it a new name. Ex:
mv this.one that.one renames a file.
mv this.one ~/Pictures/Vacation/ puts the file this.one into the
- cp copy a file from one place to another. Ex:
cp this.one this_01.one will copy
this.one to another file
this_01.one. Add directories for more fun:
cp ~/Pictures/Vacation/saturn.jpg /Users/otherone/Pictures/Vacation/saturn.jpg.
- rm remove a file. delete it, and beware!. Use the
-r to make it recursive to delete a directory. Ex:
rm this.one deletes that file.
rm -r ~/Pictures/Vacation to forget the good times.
- sudo super user do. many commands need administrator-like privileges, otherwise they won’t work.
apt-get is a command that needs to be run with
sudo to allow files to be written to protected directories. You’ll see
sudo as the first word in a lot of commands – all it is doing is giving the command the necessary access. You’ll be asked for a password the first time you use
sudo. The default password and user is “chip”.
- apt-get the command used for installing, removing, and finding software for Debian Linux systems, such as the CHIP Operating System.
sudo apt-get install puredata installs the Pure Data program and any dependencies.
sudo apt-get remove puredata will remove the program.
sudo apt-cache search image will search apt repositories for the keyword search. And so on.
- pwd present working directory. In case you forget where you are. Not much to it:
pwd will output the directory name, such as
- grep a tool used for searching through files. It’s quite deep and can be complicated, but if you see the word
grep in some command, you know it’s searching for a match.
- | (pipe) a command used to redirect data into an application.
- < (redirect) a command use to redirect data into a file.
- cat and echo concactenate. append data to a file. Ex:
echo "Last line of text" >> sometext.txt. Merge files:
cat append.txt >> main.txtwill put all the text in append.txt into main.txt. Overwrite:
echo "New contents of text file" > whatevs.txt will replace all text in the file with the text in quotes. Display text in file:
cat showit.txt will print the contents in the terminal window. Create:
cat > new.txt will let you create a new text file in the terminal by typing lines (ctl-c to exit).
- less makes it so you can paginate and read a text tile. Ex:
less longtext.txt will fill the screen with the first part of the longtext.txt file. Use the space bar to view the next page. Type
q to exit.
- nano a text editor. You’ll often see commands that call
nano so you can edit a configuration. Ex:
nano /etc/avahi/services/afpd.service to edit the avahi Apple file service file.
- find look for files in the filesystem. Ex:
find ~/Documents -name particular.txt -type f will look for the file with the name
particular.txtin the Documents directory.
- chmod change mode. Used for file permissions, which can be important when sharing things on the network, scripting actions, and many more reasons.
- htop display the processes currently alive on the CPU. If things seem slow, or you want to see how much CPU or memory a program is using, just type
htop to see a table of all running processes, then type
q when you want to exit.
- scp secure copy. copy a file from one computer to another over a network. Ex:
scp Pictures/Vacation/motel.jpg Pictures/Vacation/accident.jpg firstname.lastname@example.org:~/Pictures copies a couple jpegs to another computer on the network.
- ssh secure shell. access another computer on the network and use the terminal commands to make changes and control it. Ex:
ssh email@example.com to access your CHIP on a local network.
- CTRL C if you can’t use the terminal because a process is taking too long, type CTRL-C on your keyboard to cancel the most recent command.
- http://net-newbie.com/linux/commands/vi.html – ｖｉエディタの使い方