2018年11月16日金曜日

Raspberry Pi で Samba

Raspberry Pi に保存したファイルを Windows に移動させたかったので Raspberry Pi に Samba を入れま した。

環境

  • Raspberry Pi 3 Model B
  • Raspbian GNU/Linux 9.4 (stretch)

Samba インストール

$ sudo apt install samba

設定

設定ファイルを確認すると以下の様にすでにホームディレクトリの設定が有効になっていました。

$ cat /etc/samba/smb.conf
... snip ...
[homes]
   comment = Home Directories
   browseable = no

# By default, the home directories are exported read-only. Change the
# next parameter to 'no' if you want to be able to write to them.
   read only = yes

# File creation mask is set to 0700 for security reasons. If you want to
# create files with group=rw permissions, set next parameter to 0775.
   create mask = 0700

# Directory creation mask is set to 0700 for security reasons. If you want to
# create dirs. with group=rw permissions, set next parameter to 0775.
   directory mask = 0700

# By default, \\server\username shares can be connected to by anyone
# with access to the samba server.
# The following parameter makes sure that only "username" can connect
# to \\server\username
# This might need tweaking when using external authentication schemes
   valid users = %S

# Un-comment the following and create the netlogon directory for Domain Logons
# (you need to configure Samba to act as a domain controller too.)
;[netlogon]
... snip ...

pi ユーザーを smbpasswd に登録してパスワードを設定

$ sudo smbpasswd -a pi
New SMB password:
Retype new SMB password:
Added user pi.

接続

\\XX.XX.XX.XX\pi で Windows から接続できました。(XX.XX.XX.XX は Raspberry Pi の IP アドレスです)

2018年11月14日水曜日

apt-file でどのパッケージに指定したファイルが含まれているか探す

環境

  • Raspberry Pi 3 model B
  • Raspbian GNU/Linux 9.4 (stretch)

apt-file インストール

$ sudo apt-get install apt-file

パッケージ情報を更新

$ sudo apt update

グルると更新のために $ sudo apt-file update を実行と記載されていたりしますが、man を調べると

$ man apt-file
... snip ...
       update
           Deprecated action that just calls "apt update".
... snip ...

と書かれているので、パッケージ情報の更新は $ sudo apt update で良いようです。

試しに検索

例えば /usr/bin/pip2 を含むパッケージを探すと

$ apt-file search /usr/bin/pip2
python-pip: /usr/bin/pip2

となり、/usr/bin/pip2 ファイルは python-pip パッケージに含まていることがわかりました。