2017年2月9日木曜日

一番簡単なSamba設定(ホームディレクトリ編)

一番簡単なSambaサーバ設定 では、共有ディレクトリを作って公開しましたが、それも面倒で、自分のホームディレクトリを自分にすべてWindows側からフルアクセスできるようにしたい場合です。
ユーザ名 hogeuser と仮定して説明します。
/home/hogeuser
が既にできているはずです。

$ vi /etc/samba/smb.conf
以下の内容にする
[global]
unix charset = UTF-8
dos charset = CP932

        workgroup = WORKGROUP
        server string = Samba Server Version %v

        # logs split per machine
        log file = /var/log/samba/log.%m
        # max 50KB per log file, then rotate
        max log size = 50

        security = user
        passdb backend = tdbsam
[homes]
        comment = Home Directories
        browseable = no
        writable = yes
;       valid users = %S
;       valid users = MYDOMAIN\%S
        create mask 0644
        directory mask = 0755

        path=/home/%S


$ sudo smbpasswd -a hogeuser
:
: <- パスワードを指定する

でOKです.

Ubuntuの場合
$ sudo service smbd restart

CentOSの場合
# /etc/init.d/samba restart

です。

Windowsのコマンドプロンプトで、
>net use v: \\172.16.1.4\hogeuser /user:hogeuser password
か、エクスプローラーのネットワークドライブの割り当てで設定します。
(172.16.1.4の部分はWindowsからアクセス可能なLinuxサーバ、仮想マシンのIPアドレスです)



2017年2月3日金曜日

Linux: スペースを含むファイル名のfind xargsでの処理(Busybox)

通常のLinuxでは以下のように処理すれば問題ない。


60日以前のファイルをすべて削除する

find .  -mtime +60 -print0 | xargs -0 rm -f

しかし、Busyboxのfindにはprint0が効かないは、xargsに-0もない
なので以下で代替

find .  -mtime +60 | sed -e 's/ /\\ /g' | xargs rm -f

なんてことはないが30分くらいハマった