Samba Server in CentOS / RHEL 7
Samba is comprised of three daemons: smbd, nmbd, and winbindd.
You may need to create a user:
[samba_share]
comment = Samba share
path = /samba_share
valid users = behnam behdad
public = no
browseable = yes
valid users = bp
writable = yes
create mask = 0765
And enable and then start the service:
To specify the Windows workgroup and a brief description of the Samba server:
workgroup = BEHNAMWORKGROUP
server string = Behnam's Samba Server
Important: To set up a Windows domain member server, you must first join the domain using the net join command before starting the smb service. Also you'd better run winbind service before smbd.
Mote: When the /etc/samba/smb.conf file is changed, Samba automatically reloads it after a few minutes. Issuing a manual restart or reload is also effective.
[global]
workgroup = WORKGROUP
server string = my Samba server
netbios name = bp-samba
name resolve order = bcast host
dns proxy = no
log file = /var/log/samba/%m.log
create mask = 0664
directory mask = 0775
force create mode = 0664
force directory mode = 0775
security = user
map to guest = Bad User
max log size = 50
[Share]
path = /home/samba_share
public = yes
only guest = yes
writable = yes
To exit smbclient, type exit at the smb:\> prompt.
Mounting Windows or Samba share in Linux:
Note 2: For permanent mount, create a proper entry in /etc/fstab.
The following example displays a list of the available shares for a host named behnam-pc:
The testparm program checks the syntax of the /etc/samba/smb.conf file. it also displays a summary of your smb.conf config file after testing.
The wbinfo program displays information from the winbindd daemon. The winbindd daemon must be running for wbinfo to work.
- smbd daemon provides file sharing and printing services to clients as well as user authentication, resource locking, and data sharing through the SMB protocol. The default ports of smbd are 139 tcp and 445 tcp. The smbd daemon is controlled by the smb service.
- The nmbd daemon deals with NetBIOS protocol. It means it participates in the browsing protocols that make up the Windows Network Neighborhood. The default port for NMB is 137 udp. The nmbd daemon is controlled by the nmb service.
- The winbind service resolves user and group information received from a Windows server. This makes Windows users and groups information understandable by our Linux system. The winbindd daemon is controlled by the winbind service and does not require the smb service to be started in order to operate.
# yum install samba*Then create a directory to share:
# mkdir /samba_shareChange the SELinux file context so that it can be shared:
# chmod 777 /samba_share
# chcon -t samba_share_t /samba_share/or easily disable SE Linux by editing /etc/sysconfig/selinux or /etc/selinux/config if security is not important for you.
You may need to create a user:
# useradd behnamPut the following lines in /etc/samba/smb.conf to create a share directory:
# paaswd behnam
# smbpasswd -a behnam
[samba_share]
comment = Samba share
path = /samba_share
valid users = behnam behdad
public = no
browseable = yes
valid users = bp
writable = yes
create mask = 0765
And enable and then start the service:
# systemctl enable smb.service
# systemctl start smb.serviceDo not forget to open the appropriate ports on firewall:
#firewall-cmd –-permanent –-add-service=samba
#systemctl restart firewalld
To specify the Windows workgroup and a brief description of the Samba server:
workgroup = BEHNAMWORKGROUP
server string = Behnam's Samba Server
Important: To set up a Windows domain member server, you must first join the domain using the net join command before starting the smb service. Also you'd better run winbind service before smbd.
Mote: When the /etc/samba/smb.conf file is changed, Samba automatically reloads it after a few minutes. Issuing a manual restart or reload is also effective.
Sample config file:
Another simple sample file might be as follow:[global]
workgroup = WORKGROUP
server string = my Samba server
netbios name = bp-samba
name resolve order = bcast host
dns proxy = no
log file = /var/log/samba/%m.log
create mask = 0664
directory mask = 0775
force create mode = 0664
force directory mode = 0775
security = user
map to guest = Bad User
max log size = 50
[Share]
path = /home/samba_share
public = yes
only guest = yes
writable = yes
Related Tools:
If you want to access the share folder via a Linux client:$ smbclient //<hostname>/<share-name> -U <username>Note: If the -U switch is not used, the username of the current user is passed to the Samba server.
To exit smbclient, type exit at the smb:\> prompt.
Mounting Windows or Samba share in Linux:
# mount -t cifs //<servername>/<share-name> /mnt/point/ -o username=<username>,password=<password>Note 1: make sure the cifs-utils rpm is installed on your system.
Note 2: For permanent mount, create a proper entry in /etc/fstab.
The following example displays a list of the available shares for a host named behnam-pc:
$ net -l share -S behnam-pcThe following example displays a list of Samba users for a host named behnam-pc:
$ net -l user -S behnam-pcThe nmblookup tool resolves NetBIOS names into IP addresses. nmblookup broadcasts its query on the local subnet until the target machine replies.
$ nmblookup anarpdbedit is a tool to manage accounts located in the SAM database:
$ pdbedit -a behnamThe smbcacls program modifies Windows ACLs on files and directories shared by a Samba server or a Windows server:
# smbcacls <//server/share> <filename> <options>The smbstatus program displays the status of current connections to a Samba server.
The testparm program checks the syntax of the /etc/samba/smb.conf file. it also displays a summary of your smb.conf config file after testing.
The wbinfo program displays information from the winbindd daemon. The winbindd daemon must be running for wbinfo to work.
<< Home