CSIA 430 Linux Administration – Samba Installation and Configuration Command Reference

This page contains the commands used in the videos for installing and configuring the Samba service on a Linux server. It also contains a reference for testing with Windows clients.

  1. Install the samba package

# yum install samba samba-client samba-common
or
# yum install samba*

  1. Create a directory to share and set permissions and ownership

# mkdir -p /srv/samba/Linuxanonymous

# chmod -R 0775 /srv/samba/Linuxanonymous

# chown -R nobody:nobody /srv/samba/Linuxanonymous

  1. Change the SELinux context to allow Samba to read and write from the directory

# chcon -t samba_share_t /srv/samba/Linuxanonymous

  1. Edit the Samba Configuration file /etc/samba/smb.conf
    Make a copy of the original configuration file, just in case …

# cp /etc/samba/smb.conf /etc/samba/smb.conf.orig

[global]
       #This must match the Windows WORKGROUP Name
        workgroup = WORKGROUP
       #Name that will appear in Windows when browsing network
        netbios name = centos
        security = user
       #Required for some versions of Windows
        ntlm auth = yes
        map to guest = Bad User
[linuxanonymous]
       # Just a comment, in case you have multiple shares
        comment = Anonymous File Server Share
       # Must be the path to the share you created, and the directory 
       # name must match the [sectionName]
        path = /srv/samba/linuxanonymous
        browsable =yes
        writable = yes
        guest ok = yes
        read only = no
        force user = nobody

5. Test the parameter file

# testparm

  1. Start the service(s)

# systemctl enable smb.service
# systemctl enable nmb.service
# systemctl start smb.service
# systemctl start nmb.service

  1. Add a firewall rule
    # firewall-cmd --permanent --zone=public --add-service=samba
    # firewall-cmd --reload
  1. Test locally (on the Linux VM) by opening Files Tool and connecting to:

smb://127.0.0.1/linuxanonymous

9. Test from Windows by:

  • Opening Windows Explorer
  • In the left pane, select This PC
  • In the top menus, select Computer
  • Select Map Network Drive > Map Network Drive
  • Uncheck the Reconnect at Sign-in box
  • In the Folder box enter \\192.168.nnn.hhh\shareName – where nnn.hhh is the network and host portion of the IP address for the Linux server running the Samba service and shareName is the name of the Samba share.

10. Windows 10 Education Edition required this change to registry
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters

Change AllowInsecureGuestAuth from 0 to 1