安裝配置samba (Install and Configure Samba)

參考資料:https://ubuntu.com/tutorials/install-and-configure-samba#1-overview

1. Overview

A Samba file server enables file sharing across different operating systems over a network. It lets you access your desktop files from a laptop and share files with Windows and macOS users.

This guide covers the installation and configuration of Samba on Ubuntu.
What you’ll learn

How to set up a Samba file server
How to share files across a local network

What you’ll need

Ubuntu 16.04 LTS
A Local Area Network (LAN) to share files over

If you have everything ready, let’s dive straight into the installation process on the next step!

Originally authored by Aden Padilla.

2. Installing Samba

To install Samba, we run:

sudo apt update
sudo apt install samba

We can check if the installation was successful by running:

whereis samba

The following should be its output:

samba: /usr/sbin/samba /usr/lib/samba /etc/samba /usr/share/samba /usr/share/man/man7/samba.7

3. Setting up Samba

Now that Samba is installed, we need to create a directory for it to share:

mkdir /home/<username>/sambashare/

The command above creates a new folder sambashare in our home directory which we will share later.

The configuration file for Samba is located at /etc/samba/smb.conf. To add the new directory as a share, we edit the file by running:

sudo nano /etc/samba/smb.conf

At the bottom of the file, add the following lines:

[sambashare]
comment = Samba on Ubuntu
path = /home/username/sambashare
read only = no
browsable = yes

Then press Ctrl-O to save and Ctrl-X to exit from the nano text editor.
What we’ve just added

    comment: A brief description of the share.

path: The directory of our share.

read only: Permission to modify the contents of the share folder is only granted when the value of this directive is no.

browsable: When set to yes, file managers such as Ubuntu’s default file manager will list this share under “Network” (it could also appear as browseable).

Now that we have our new share configured, save it and restart Samba for it to take effect:

sudo service smbd restart

Update the firewall rules to allow Samba traffic:

sudo ufw allow samba

## 4. Setting up User Accounts and Connecting to Share

<article class="l-tutorial-section__content">

Since Samba doesn’t use the system account password, we need to set up a Samba password for our user account:

sudo smbpasswd -a username

Note
Username used must belong to a system account, else it won’t save.

Connecting to Share

On Ubuntu: Open up the default file manager and click Connect to Server then enter:

ubuntuctn

On macOS: In the Finder menu, click Go > Connect to Server then enter:

macosctn

On Windows, open up File Manager and edit the file path to:

\\ip-address\sambashare

Note: ip-address is the Samba server IP address and sambashare is the name of the share.

You’ll be prompted for your credentials. Enter them to connect!
Samba

If you’d like to take your configuration further…

Samba Server Guide

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末跋核,一起剝皮案震驚了整個(gè)濱河市率挣,隨后出現(xiàn)的幾起案子智什,更是在濱河造成了極大的恐慌,老刑警劉巖删豺,帶你破解...
    沈念sama閱讀 212,718評(píng)論 6 492
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件尘分,死亡現(xiàn)場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,683評(píng)論 3 385
  • 文/潘曉璐 我一進(jìn)店門螃成,熙熙樓的掌柜王于貴愁眉苦臉地迎上來宁炫,“玉大人罩阵,你說我怎么就攤上這事。” “怎么了谎懦?”我有些...
    開封第一講書人閱讀 158,207評(píng)論 0 348
  • 文/不壞的土叔 我叫張陵截碴,是天一觀的道長。 經(jīng)常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 56,755評(píng)論 1 284
  • 正文 為了忘掉前任该编,我火速辦了婚禮硕淑,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己谒拴,他們只是感情好惭聂,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,862評(píng)論 6 386
  • 文/花漫 我一把揭開白布炮温。 她就那樣靜靜地躺著,像睡著了一般送火。 火紅的嫁衣襯著肌膚如雪镜盯。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 50,050評(píng)論 1 291
  • 那天艺糜,我揣著相機(jī)與錄音晤碘,去河邊找鬼宠蚂。 笑死求厕,一個(gè)胖子當(dāng)著我的面吹牛项栏,可吹牛的內(nèi)容都是我干的币厕。 我是一名探鬼主播访递,決...
    沈念sama閱讀 39,136評(píng)論 3 410
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢(mèng)啊……” “哼烟瞧!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起染簇,我...
    開封第一講書人閱讀 37,882評(píng)論 0 268
  • 序言:老撾萬榮一對(duì)情侶失蹤参滴,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后锻弓,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體砾赔,經(jīng)...
    沈念sama閱讀 44,330評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,651評(píng)論 2 327
  • 正文 我和宋清朗相戀三年青灼,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了暴心。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 38,789評(píng)論 1 341
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡聚至,死狀恐怖酷勺,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情扳躬,我是刑警寧澤脆诉,帶...
    沈念sama閱讀 34,477評(píng)論 4 333
  • 正文 年R本政府宣布,位于F島的核電站贷币,受9級(jí)特大地震影響击胜,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜役纹,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 40,135評(píng)論 3 317
  • 文/蒙蒙 一偶摔、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧促脉,春花似錦辰斋、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,864評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至旁仿,卻和暖如春藕夫,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 32,099評(píng)論 1 267
  • 我被黑心中介騙來泰國打工毅贮, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留办悟,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 46,598評(píng)論 2 362
  • 正文 我出身青樓滩褥,卻偏偏與公主長得像病蛉,于是被迫代替她去往敵國和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子铸题,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,697評(píng)論 2 351

推薦閱讀更多精彩內(nèi)容