Tất cả các bài viết liên quan đến IT, Infrastructure: Sysadmin, Cloud & DevOps...chuyển qua https://infra.lecuong.info/

Build Files server on CentOS

Build File server to share files between Windows computer and Linux Server computer.

1. Install Samba

[root@lecuong.info ~]#  yum -y install samba

2.Configure Samba :  Create a shared directory that anybody can read and write,

a.No Authentication

[root@lecuong.info ~]# mkdir /mnt/D/share

[root@lecuong.info ~]# chmod 777 /mnt/D/share

[root@lecuong.info ~]# vi /etc/samba/smb.conf




unix charset = UTF-8 // add the line

workgroup = WORKGROUP //(Windows' default)

security = share

hosts allow = 127. 192.168.1. //change IP address you permit


// add these lines

[share] // change to any name you like

path = /mnt/D/share // shared directory

writable = yes

guest ok = yes

guest only = yes

create mode = 0777 // fully accessed

directory mode = 0777 // fully accessed

share modes = yes


[root@lecuong.info ~]# /etc/rc.d/init.d/smb start

Starting SMB services:[ OK ]

Starting NMB services:[ OK ]

[root@lecuong.info ~]# chkconfig smb on


Now, you can access to shared directory name "share" on CentOS server.

b.Requires user authentication.

[root@lecuong.info ~]# groupadd banbeit

[root@lecuong.info ~]#  mkdir /home/security

[root@lecuong.info ~]#  chgrp banbeit /home/security

[root@lecuong.info ~]# chmod 0770 /home/security

[root@lecuong.info ~]#  vi /etc/samba/smb.conf


security = user

[Security] // change to any name you like

path = /home/security
writable = yes
create mode = 0770
directory mode = 0770
share modes = yes
guest ok = no
valid users = @banbeit // allow only banbeit group


[root@lecuong.info ~]#  /etc/rc.d/init.d/smb restart

Shutting down SMB services:[ OK ]

Shutting down NMB services:[ OK ]

Starting SMB services:[ OK ]

Starting NMB services:[ OK ]


Add your existing users to samba or create new users and then add them to samba.

[root@lecuong.info ~]#  smbpasswd -a MrCuong    // add an existing user in Samba

New SMB password:                              // set password

Retype new SMB password:                    // verify

Now, you can access to shared directory name "security" on CentOS server with username & password.


Orther:Configure Samba from Web browser

1.Install and config xinetd:


[root@lecuong.info ~]# yum -y install xinetd

[root@lecuong.info ~]# /etc/rc.d/init.d/xinetd start

Starting xinetd: [ OK ]

[root@lecuong.info ~]# chkconfig xinetd on

2.Install SWAT

[root@lecuong.info ~]# yum -y install samba-swat

[root@lecuong.info ~]# vi /etc/xinetd.d/swat


only_from = 127.0.0.1 192.168.1.2/24 // add IPs you permit

disable = no



[root@lecuong.info ~]# /etc/rc.d/init.d/xinetd restart

Stopping xinetd: [ OK ]

Starting xinetd: [ OK ]


Now. you can access to http://your-hostname:901, login with user name and password for root, then you can configure samba on browser.

Have a nice day for all member of www.lecuong.info and visitor !! 



Viết nhận xét

Các bạn có thể viết lời nhận xét cho bài viết, nhưng cần tuân thủ một số quy tắc sau:

» Các nhận xét/bình luận phải nghiêm túc, không dung tục, không spam.
» Nội dung phải liên quan tới chủ đề bài viết.
» Viết bằng tiếng việt có dấu hoặc tiếng Anh. Nội dung viết không dấu sẽ bị xóa.
» Hãy để lại tên của bạn khi nhận xét/bình luận, để tôi có thể dễ dàng trả lời bạn khi cần.

Chúc các bạn tìm được những kiến thức bổ ích khi tình cờ ghé thăm blog này.