Samba Configuration on Linux

Linux上的Samba配置

Through Samba, we can mount folders from Linux to Windows. After deploying Samba on a Linux virtual machine, I can use the remote compilation plugin I wrote a few days ago (sublimeRemoteCompile) to write code on Windows! It’s quite enjoyable. Today, I will briefly record how to configure Samba sharing on the server for friends with similar needs.

Note: Do not use NAT for VMware virtual machines; choose bridge mode, otherwise, it might not be on the same network segment as the host, and SSH may fail to connect.

Installation

1
sudo apt-get install samba

Edit the configuration file

First, back up the default configuration file:

1
sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.bak

Then create a smb.conf file under /etc/samba:

1
sudo nano /etc/samba/smb.conf

Fill in the following configuration (a configuration that requires account login and is readable and writable):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[global]
workgroup = WORKGROUP
server string = Samba Server Version %v
security = user
passdb backend = tdbsam
load printers = yes
cups options = raw
create mode = 0777
force create mode = 0777
directory mode = 0777
force directory mode = 0777
[Linux]
comment = share all
path = /home/visionsmile
writeable = yes
read only = no
browseable = yes
public = no

Regarding those modes (create/force create/directory/force directory) permissions, if it’s only for personal use, it’s recommended to set it to 777 because if set to 755, the following error might occur:

1
2
/usr/bin/ld: cannot open output file 1: Permission denied
clang: error: linker command failed with exit code 1 (use -v to see invocation)

For the above smb.conf, you need to create the folder at the path specified.
Change the permissions of the path directory to 755:

1
sudo chmod -R 755 /home/visionsmile

Create a samba account (Note: this account must exist in your local system, for example, root):

1
pdbedit -a root

You will be prompted to enter the password for the samba account.
Check the samba accounts:

1
pdbedit -L

Then you can start samba:

1
2
3
4
# Start
sudo /etc/init.d/samba start
# Restart
sudo /etc/init.d/samba restart

Startup Errors

If you encounter the following issues when starting:


This situation arises because

  1. The operating system is Debian 8 or higher, and Samba Server version is 4.2 or higher.
  2. Samba 4 does not support security = share; you can either remove it or change it to security = user.

Mapping to Local on Windows

Open My Computer -> Map Network Drive.

After entering the samba account password you created, you can see the shared folder:

Reference Articles

The article is finished. If you have any questions, please comment and communicate.

Scan the QR code on WeChat and follow me.

Title:Samba Configuration on Linux
Author:LIPENGZHA
Publish Date:2017/02/04 05:29
Word Count:1.6k Words
Link:https://en.imzlp.com/posts/17347/
License: CC BY-NC-SA 4.0
Reprinting of the full article is prohibited.
Your donation will encourage me to keep creating!