How to install/configure Samba basics on CentOS7

Install Samba

# yum -y install samba*

Enable Samba

# systemctl start smb
# systemctl enable smb

Sample configuration

The sample configuration below can be used to get access to your linux root folder via \\ip-address\root$ with the user root.

# cat /etc/samba/smb.conf

# See smb.conf.example for a more detailed config file or
# read the smb.conf manpage.
# Run 'testparm' to verify the config is correct after
# you modified it.

[global]
workgroup = SAMBA
security = user
passdb backend = tdbsam
printing = cups
printcap name = cups
load printers = yes
cups options = raw

[homes]
comment = Home Directories
valid users = %S, %D%w%S
browseable = No
read only = No
inherit acls = Yes

[printers]
comment = All Printers
path = /var/tmp
printable = Yes
create mask = 0600
browseable = No

[print$]
comment = Printer Drivers
path = /var/lib/samba/drivers
write list = root
create mask = 0664
directory mask = 0775

[root$]
force user = root
create mask = 0755
writeable = yes
browsable = yes
path = /

Manage Samba users

In this example a new Linux user called ‘admin’ will be created/modified/removed and this user will be added to the samba configuration.

Add users

# useradd admin
# passwd admin
# smbpasswd -a admin

Modify users

# passwd admin
# smbpasswd admin

Remove users

# smbpasswd -x admin
# userdel -r admin

Allowing user to access samba share

Configure the Samba share in the /etc/samba/smb.conf configuration file to allow the new user to browse the share:

# vi /etc/samba/smb.conf
[share1]
comment = A Shared Directory
path = /var/tmp/sharedir
valid users = admin
public = no
writable = yes

Reload the smb.conf configuration file with below command.

# systemctl reload smb

Mount driveletter from windows

To mount the example above, use this command on Windows cmd.exe-terminal:

net use L: \\ip-address\root$ /user:root your_password

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.