I'm Tiến. In this post I'll show you how to setup a basic Samba Server, and how to access those shares from client (Windows, Linux)
Samba has a vast array of options and configuration settings, but here I'll show you how to setup and configure a basic Samba Server with one user.
First, you need to install Samba:
sudo apt-get install sambaEnter your password to authenticate, and apt will download and install Samba and its attendant utilities for you.
It's important to realize about Samba is that it stores its own set of user accounts, separate from the main accounts, in the /etc/samba/smbpasswd file. That mean, you'll need to create a separate Samba password for every user you want to access your file shares. You create a password using smbpasswd command. For example, to create a command for a user named tienpt, here is how the command should look:
sudo smbpasswd -a tienpttienpt's password is created. The next step is to create a home directory for him to share. Begin by creating a folder "Samba" as bellow:
mkdir /home/tienpt/SambaNote: don't use sudo to create, because then the owning user and group will be set as "root", which means you won't be able to access the folder using your Samba user name and password.
The next step is to edit the /etc/samba/smb.conf, the main configuration Samba. Please kindly backup before continuing:
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bakNow, start:
sudo vi /etc/samba/sm.conf"Please kindly read fully"
Example:Note: there should be no spaces between the lines and note aslo that there should be a single space both before and after each of the equal signs)
[Test]
path = /home/tienpt/Samba
available = yes
valid users = tienpt
read only = no
browsable = yes
public = yes
writable = yes
Detail:
[Test] gives the name of the file share.Restart Samba with this command:
"path" specifiles the location of the folder to shared.
"available" specifiles that the file share is available to clients on the network.
"vaild users" user allow to access the file share.
"read only" client will be allowed to write to the file share.
"writable" data can be written to the file share.
sudo restart smbdThis will force Samba to restart, re-reading its confifuration files and activating the share you just created. Once Samba has restarted, use this command to check your smb.conf for any synctax errors:
sudo testparmIf you pass the testparm command, Samba should be working. Try accessing the share from another client on your LAN.
======================== Auto start ========================
PhanTheTien ~ # cat /etc/init/smbd.conf
description "SMB/CIFS File Server"
author "Steve Langasek <steve.langasek@ubuntu.com>"
start on (local-filesystems and net-device-up)
stop on runlevel [!2345]
respawn
pre-start script
RUN_MODE="daemons"
[ -r /etc/default/samba ] && . /etc/default/samba
[ "$RUN_MODE" = inetd ] && { stop; exit 0; }
install -o root -g root -m 755 -d /var/run/samba
end script
exec smbd -F
0 nhận xét:
Post a Comment