【教程】ubuntu下安装samba服务器

一、准备工作

  首先更新 software sources, 找到最快的源 

lcw@ubuntu:~$ sudo apt-get update

二、安装samba

lcw@ubuntu:~$ sudo apt-get install samba smbfs samba-common smbclient

三、创建samba配置文件

1. 保存现有的配置文件 

lcw@ubuntu:~$ sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak

2. 编辑配置文件

lcw@ubuntu:~$ sudo vim /etc/samba//smb.conf

  在smb.conf最后添加

[username] 

path=/home/username 

available=yes 

browseable=yes 

public=yes 

writable =yes 

   (注意: 上面的设置中,username 换成你的用户名如果在前面有“#”,需要先把它去掉,path必须是已经创建的路径

四、创建samba帐户

lcw@ubuntu:~$ sudo smbpasswd -a lcw

  Lcw换成自己的用户名

  这里会要求你输入samba帐户的密码

lcw@ubuntu:~$ sudo smbpasswd -a lcw

New SMB password:

Retype new SMB password:

Added user lcw.

lcw@ubuntu:~$ 

五、重启samba服务器

lcw@ubuntu:~$ sudo /etc/init.d/smbd reload

Rather than invoking init scripts through /etc/init.d, use the service(8)

utility, e.g. service smbd reload

 

Since the script you are attempting to invoke has been converted to an

Upstart job, you may also use the reload(8) utility, e.g. reload smbd

lcw@ubuntu:~$ 

  修改过smb.conf 的话要执行一次

lcw@ubuntu:~$ sudo /etc/init.d/smbd restart

Rather than invoking init scripts through /etc/init.d, use the service(8)

utility, e.g. service smbd restart

 

Since the script you are attempting to invoke has been converted to an

Upstart job, you may also use the stop(8) and then start(8) utilities,

e.g. stop smbd ; start smbd. The restart(8) utility is also available.

smbd stop/waiting

smbd start/running, process 5886

lcw@ubuntu:~$ 

六、测试

  到windows下输入ubuntu ip试一下

  在“我的电脑”或者在“运行”处输入“\+ubuntu机器的ip”即可

 

原文地址:https://www.cnblogs.com/lcw/p/3200874.html