Share This
//Cài đặt File server Samba để sharing

Cài đặt File server Samba để sharing

Cấu trúc File Server Windows

– Làm server Linux thành File Server cho Windowns

– Ở đây cài đặt Samba, thiết lập để có thể truy cập đến Home Directory của các User từ Windowns

– Thêm nữa, tạo Sharing Folder để toàn bộ các Users có thể truy cập

– Thiết lập để có thể truy cập Samba server từ trong nội bộ hệ thống mạng

■ Cài đặt Samba
[root@centos ~]# yum -y install samba

■  Thiết lập Samba

1) Trường hợp tạo mới một User

→ Đăng ký một User mới đến Linux
[root@centos ~]# useradd centos

→ Thiết lập password
[root@centos ~]# passwd centos

Changing password for user centos.

New password:

Retype new password:

password: all authentication tokens updated successfully.

2) Trường hợp sử dụng một user đã có để là user truy cập vào server Samba thì làm từ đây

→ Lấy User đã đăng ký trong Linux để làm user truy nhập server Samba theo hình thức đăng ký mới (ví dụ : centos)
[root@centos ~]# pdbedit -a centos

new password:

retype new password:
startsmbfilepwent_internal: file /etc/samba/smbpasswd did not exist. File successfully created.

Unix username: centos

NT username:

Account Flags: [U ]

User SID: S-1-5-21-1397570601-503051572-2212552623-2000

Primary Group SID: S-1-5-21-1397570601-503051572-2212552623-2001

Full Name:

Home Directory: \\linux\centos

HomeDir Drive:

Logon Script:

Profile Path: \\linux\centos\profile

Domain: LINUX

Account desc:

Workstations:

Munged dial:

Logon time: 0

Logoff time: 土, 14 12月 1901 05:45:51 GMT

Kickoff time: 土, 14 12月 1901 05:45:51 GMT

Password last set: 月, 13 12月 2004 16:06:00 GMT

Password can change: 月, 13 12月 2004 16:06:00 GMT

Password must change: 土, 14 12月 1901 05:45:51 GMT

Last bad password : 0

Bad password count : 0

Logon hours : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

Tạo thư mục Home (Cái này khi Khôi thực hiện thì không làm đến )

1) Xử lý cho User mới tạo

→ Tạo Directory cho samba khi tạo user mới
[root@centos ~]# mkdir /etc/skel/samba

2) Xử lý cho User đã có sẵn

→ Tạo script tạo directory cho samba với user đã có sẵn
[root@centos ~]# vi mkhomedir.sh
#!/bin/bash

for user in $(ls /home)

do

id $user > /dev/null 2>&1

[ $? -eq 0 ] && \

[ ! -d /home/$user/samba ] && \

mkdir /home/$user/samba && \

chown $user:$user /home/$user/samba && \

echo “/home/$user/samba create”

done

→ Thực thi script tạo thư mục cho samba với User đã có sẵn
[root@centos ~]# sh mkhomedir.sh

→ Xóa script tạo Directory cho samba với User đã có sẵn
[root@centos ~]# rm -f mkhomedir.sh

Tạo thư mục dùng chung

→ Tạo Directory dùng chung có thể truy cập cho toàn bộ User
[root@centos ~]# mkdir /home/samba

→ Thay đổi người sở hữu thư mục dùng chung
[root@centos ~]# chown nobody:nobody /home/samba

※※※※※※※※※※※※※※※

※ Trường hợp Khôi tạo : ※
※※※※※※※※※※※※※※※

→ Tạo thư mục Public nằm trong Home
[root@vietnam home]# mkdir public

→ Thay đổi quyền cho thư mục Home (full quyền)
[root@vietnam ~]# chmod 777 /home/

→ Gán full quyền cho all user đối với thư mục public
[root@vietnam ~]# chmod 777 /home/public/

Thiết lập cho Samba

→ Thay đổi file setting Samba
[root@centos ~]# vi /etc/samba/smb.conf
[global]

→ Insert (Mã code font tiếng nhật cho Linux)
unix charset = UTF-8

→ Insert (Mã code font tiếng nhật cho Windows)
dos charset = CP932

→ Insert (Mã code font tiếng nhật cho Windows)
display charset = UTF-8

# workgroup = NT-Domain-Name or Workgroup-Name
workgroup = MYGROUP

→ Update (chỉ định tên WorkGroup của Windows)
workgroup = WORKGROUP

※Properties của Windows ⇒ Tham khảo cột WorkGroup của Tab tên Computer

→ Insert (Thay đổi để có thể truy cập từ bên trong – nội bộ)
; hosts allow = 192.168.1. 192.168.2. 127.
hosts allow = 192.168.1. 127.

# If you want to automatically load your printer list rather
# than setting them up individually then you’ll need this

※Trường hợp không sharing Printer bởi Samba

→ Thêm dấu ; ở đầu hàng (Để vô hiệu hóa việc sharing Printer)
; load printers = yes

→ Insert (Vô hiệu hóa việc sharing Printer)
load printers = no

→ Insert (Vô hiệu hóa việc Sharing Printer )
disable spoolss = yes

[homes]

comment = Home Directories

→ Insert (/home/UserName/Dùng samba làm Home Directory)
path = %H/samba
browseable = no
writable = yes

3) Thêm chức năng Recycle Bin chuyên dụng cho các Users

※Khi xóa File thì tự động cho chuyển đến Recycle Bin

→ Sharing Recycle Bin
vfs objects = recycle

→ Directory Name của Recycle Bin (/home/UserName/.recycle)
recycle:repository = .recycle

→ Không lưu giữ cấu trúc Directory khi chuyển đến Recycle Bin
recycle:keeptree = no

→ Chuyển đến bằng tên khác trong trường hợp trong Recycle đã có file trùng tên
recycle:versions = yes

→ Không update TimeStamp khi chuyển đến Recycle Bin
recycle:touch = no

→ Set giới hạn kích cỡ File chuyển đến Recycle Bin (0: không giới hạn )
recycle:maxsize = 0

→ Set loại file xóa lập tức không cần chuyển đến Recycle Bin
recycle:exclude = *.tmp ~$*

→ Đến đây đã thêm vào tính năng Recycle Bin dùng cho các Users

→ Thêm phần bên dưới vào cuối cùng

[public]

comment = Public Stuff

path = /home/samba

public = yes

writable = yes

only guest = yes

※Thiết lập để khi xóa File thì tự động chuyển đến Recycle Bin

→ Sharing Recycle Bin

vfs objects = recycle

→ Directory Name của Recycle Bin (/home/UserName/.recycle)

recycle:repository = .recycle

→ Không lưu giữ cấu trúc Directory khi chuyển đến Recycle Bin

recycle:keeptree = no

→ Chuyển đến bằng tên khác trong trường hợp trong Recycle đã có file trùng tên

recycle:versions = yes

→ Không update TimeStamp khi chuyển đến Recycle Bin

recycle:touch = no

→ Set giới hạn kích cỡ File chuyển đến Recycle Bin (0: không giới hạn )

recycle:maxsize = 0

→ Set loại file xóa lập tức không cần chuyển đến Recycle Bin

recycle:exclude = *.tmp ~$*

→ Đến đây đã hoàn tất việc thêm chức năng Recycle Bin của Sharing Directory

※※※※※※※※※※※※※※※

※ Trường hợp Khôi tạo : ※
※※※※※※※※※※※※※※※

→ Thay đổi file setting Samba
[root@centos ~]# vi /etc/samba/smb.conf

— Dòng 102 (:102 → dùng lệnh này sẽ chạy xuống dòng 102 của file )

→ Yêu cầu truy cập phải nhập username và password
;security = user

→ Thay đổi security để mọi người có thể truy cập được không cần pass
security = share

— Có 2 thư mục Sharing là Public và Kuhan thì set như sau

[Public]

path = /home/public

writable = yes

guest ok = yes

guest only = yes

create mode = 0777

directory mode = 0777

share modes = yes

[Kuhan]

path = /home/kuhan

writable = yes

guest ok = yes

guest only = yes

create mode = 0777

directory mode = 0777

share modes = yes

Khởi động lại Samba

→ Khởi động Samba
[root@centos ~]# /etc/rc.d/init.d/smb start

— Đang khởi động SMB service: [ OK ]

→ Khởi động nmb
[root@centos ~]# /etc/rc.d/init.d/nmb start

— Đang khởi động NMB service: [ OK ]

→ Setting để tự khởi động Samba
[root@centos ~]# chkconfig smb on

→ Setting để tự khởi động NMB
[root@centos ~]# chkconfig nmb on

— Liệt kê tình trạng các service
[root@vietnam ~]# chkconfig –list

nmb 0:off 1:off 2:on 3:on 4:on 5:on 6:off

smb 0:off 1:off 2:on 3:on 4:on 5:on 6:off

★ Link tham khảo

https://centossrv.com/samba.shtml

https://www.jitaku-server.net/samba_setup.html

https://shikichi.ddo.jp/samba.html

https://www.uetyi.mydns.jp/wordpress/linux-server/entry-23.html

https://sites.google.com/site/nakamulinux/Home/samba

https://www.obenri.com/_samba/about_samba.html

https://d.hatena.ne.jp/camellia1977/20120818/1345288125


APPLY NOW






    Benefits

    SALARY & BONUS POLICY

    RiverCrane Vietnam sympathizes staffs' innermost feelings and desires and set up termly salary review policy. Performance evaluation is conducted in June and December and salary change is conducted in January and July every year. Besides, outstanding staffs receive bonus for their achievements periodically (monthly, yearly).

    TRAINING IN JAPAN

    In order to broaden staffs' view about technologies over the world, RiverCrane Vietnam set up policy to send staffs to Japan for study. Moreover, the engineers can develop their career paths in technical or management fields.

    ANNUAL COMPANY TRIP

    Not only bringing chances to the staffs for their challenging, Rivercrane Vietnam also excites them with interesting annual trips. Exciting Gala Dinner with team building games will make the members of Rivercrane connected closer.

    COMPANY'S EVENTS

    Activities such as Team Building, Company Building, Family Building, Summer Holiday, Mid-Autum Festival, etc. will be the moments worthy of remembrance for each individual in the project or the pride when one introduces the company to his or her family, and shares the message "We are One".

    INSURANCE

    Rivercrane Vietnam ensures social insurance, medical insurance and unemployment insurance for staffs. The company commits to support staffs for any procedures regarding these insurances. In addition, other insurance policies are taken into consideration and under review.

    OTHER BENEFITS

    Support budget for activities related to education, entertainment and sports. Support fee for purchasing technical books. Support fee for getting engineering or language certificates. Support fee for joining courses regarding technical management. Other supports following company's policy, etc.

    RELATED JOBS

    © 2012 RiverCrane Vietnam. All rights reserved.

    Close