Rocky Linux 8.4にSambaファイルサーバーをインストールする

2021年10月20日

1.sambaをインストール

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
[root@localhost ~]# dnf -y install samba
インストール済み:
samba-4.13.3-4.el8_4.x86_64 samba-common-tools-4.13.3-4.el8_4.x86_64
samba-libs-4.13.3-4.el8_4.x86_64
[root@localhost ~]# dnf -y install samba 略 インストール済み: samba-4.13.3-4.el8_4.x86_64 samba-common-tools-4.13.3-4.el8_4.x86_64 samba-libs-4.13.3-4.el8_4.x86_64
[root@localhost ~]# dnf -y install samba
略
インストール済み:
  samba-4.13.3-4.el8_4.x86_64        samba-common-tools-4.13.3-4.el8_4.x86_64
  samba-libs-4.13.3-4.el8_4.x86_64

2.共有フォルダを作成
[root@localhost /]# mkdir -p /data/share
パーみっしんを設定
[root@localhost /]# chmod 777 /data/share

3.sambaの設定
[root@localhost /]# vi /etc/samba/smb.conf
文字コード、アクセスネットワーク、認証の設定

修正前

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
[global]
workgroup = SAMBA
security = user
passdb backend = tdbsam
printing = cups
printcap name = cups
load printers = yes
cups options = raw
[global] workgroup = SAMBA security = user passdb backend = tdbsam printing = cups printcap name = cups load printers = yes cups options = raw
[global]
        workgroup = SAMBA
        security = user

        passdb backend = tdbsam

        printing = cups
        printcap name = cups
        load printers = yes
        cups options = raw

修正後

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
[global]
# 文字コードを設定
unix charset = UTF-8
dos charset = CP932
# workgroupを変更
workgroup = WORKGROUP
security = user
passdb backend = tdbsam
printing = cups
printcap name = cups
load printers = yes
cups options = raw
# アクセスを許可するネットワーク
hosts allow = 192.168.0.0.
 # 認証不要
 map to guest = Bad User
[global] # 文字コードを設定 unix charset = UTF-8 dos charset = CP932 # workgroupを変更 workgroup = WORKGROUP security = user passdb backend = tdbsam printing = cups printcap name = cups load printers = yes cups options = raw # アクセスを許可するネットワーク hosts allow = 192.168.0.0.  # 認証不要  map to guest = Bad User
[global]
       # 文字コードを設定
        unix charset = UTF-8
        dos charset = CP932
       # workgroupを変更
        workgroup = WORKGROUP
        security = user

        passdb backend = tdbsam

        printing = cups
        printcap name = cups
        load printers = yes
        cups options = raw
            
        # アクセスを許可するネットワーク
        hosts allow = 192.168.0.0.
        # 認証不要
        map to guest = Bad User

4.共有フォルダーを設定
[root@localhost /]# vi /etc/samba/smb.conf
最終行に以下を追記

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
[share]
 # 共有フォルダー
path = /data/share
   # 書き込む権限を許可
writable = yes
# ゲストユーザを許可
guest ok = yes
# 全てゲストユーザー
guest only = yes
# ファイル作成
force create mode = 777
# フォルダ作成
force directory mode = 777
[share]  # 共有フォルダー path = /data/share    # 書き込む権限を許可 writable = yes # ゲストユーザを許可 guest ok = yes # 全てゲストユーザー guest only = yes # ファイル作成 force create mode = 777 # フォルダ作成 force directory mode = 777
[share]
    # 共有フォルダー
    path = /data/share
   # 書き込む権限を許可
    writable = yes
    # ゲストユーザを許可
    guest ok = yes
    # 全てゲストユーザー
    guest only = yes
    # ファイル作成
    force create mode = 777
   # フォルダ作成
    force directory mode = 777

自動起動の設定

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
[root@localhost /]# systemctl enable --now smb
Created symlink /etc/systemd/system/multi-user.target.wants/smb.service → /usr/lib/systemd/system/smb.service.
[root@localhost /]# systemctl enable --now smb Created symlink /etc/systemd/system/multi-user.target.wants/smb.service → /usr/lib/systemd/system/smb.service.
[root@localhost /]# systemctl enable --now smb
Created symlink /etc/systemd/system/multi-user.target.wants/smb.service → /usr/lib/systemd/system/smb.service.

5.Sambaサービスを許可

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
[root@localhost /]# firewall-cmd --add-service=samba
success
[root@localhost /]# firewall-cmd --runtime-to-permanent
success
[root@localhost /]# firewall-cmd --add-service=samba success [root@localhost /]# firewall-cmd --runtime-to-permanent success
[root@localhost /]# firewall-cmd --add-service=samba
success
[root@localhost /]# firewall-cmd --runtime-to-permanent
success

 

Rocky Linux 8

Posted by arkgame