SMB: Provide network shares to specific clients.

Share this link

Install the Samba package group:

# yum groupinstall -y "CIFS file server"

Create a new /etc/samba/smb.conf file and add the following lines (for a workgroup named MYGROUP, a server called MYSERVER, a local network with IP addresses in, a user named user01 and a share called shared):

workgroup = MYGROUP
server string = Samba Server Version %v
netbios name = MYSERVER
interfaces = lo eth0
hosts allow = 127. 192.168.1.
log file = /var/log/samba/log.%m
max log size = 50
security = user
passdb backend = tdbsam
comment = Shared directory
browseable = yes
path = /shared
valid users = user01
writable = yes

Note: with “passdb backend = tdbsam“, passwords are stored in the /var/lib/samba/private/passdb.tdb file.

Check the syntax of the configuration file:

# testparm

Create the shared directory:

# mkdir /shared

Set up the correct SELinux type:

# yum install -y setroubleshoot-server
# semanage fcontext -a -t samba_share_t "/shared(/.*)?"
# restorecon -r /shared

Add the following new rules to the firewall:

# iptables -I INPUT -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT
# iptables -I INPUT -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
# iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
# iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT

Save the firewall configuration:

# service iptables save

Activate Samba services at boot:

# chkconfig smb on
# chkconfig nmb on
# chkconfig winbind on

Start Samba services:

# service smb start
# service nmb start
# service winbind start

Create the samba user user01 with the password pass:

# useradd -s /sbin/nologin user01
# smbpasswd -a user01

Check the configuration:

# yum install -y samba-client
# smbclient //localhost/shared -U user01%pass
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

Leave a Reply

Please Login to comment
2 Comment threads
2 Thread replies
Most reacted comment
Hottest comment thread
3 Comment authors
scfewyyCertDepotphelun Recent comment authors
newest oldest
Notify of

Will take this exam in 2days time, just wanted to clarify, does the exam still cover CIFS? Though not so sure, I guess in Jang’s book, he mentioned that the exam does not cover samba/cifs any more. Please correct me if I’m wrong …


Where can I find an updated list of rhce exam objectives? Newer than this one:

Upcoming Events (Local Time)

  1. Feb

    1. 8:30 am - View Details
      CentOS: Dojo, Brussels, Belgium.

RHCSA7: Task of the day

Allowed time: 10 minutes.
Create an EXT4 file system mounted by UUID in /etc/fstab under /vol based on a logical volume of 28 logical extents.

RHCE7: Task of the day

Allowed time: 8 minutes.
Set up an iScsi target based on a fileio backstore of 100MB called /opt/shareddata with CHAP authentication (username=usr/password=pwd), xfs filesystem and standard firewall configuration.

Follow me on Twitter

Poll for favorite RHEL 7 book

What is your favorite RHEL 7 book to prepare RHCSA & RHCE exams?

View Results

Loading ... Loading ...

Poll for most difficult RHCSA 7 topic

What do you think is the most difficult RHCSA 7 topic?

View Results

Loading ... Loading ...

Poll for most difficult RHCE 7 topic

What do you think is the most difficult RHCE 7 topic?

View Results

Loading ... Loading ...