第一步:在终端执行 sudo apt-get install samba
而后提示:
The following packages have unmet dependencies:
samba : Depends: samba-common (= 2:4.1.6+dfsg-1ubuntu2) but 2:4.1.6+dfsg-1ubuntu2.14.04.2 is to be installed
Depends: samba-common-bin (= 2:4.1.6+dfsg-1ubuntu2) but 2:4.1.6+dfsg-1ubuntu2.14.04.2 is to be installed
Depends: samba-dsdb-modules but it is not going to be installed
Depends: samba-libs (= 2:4.1.6+dfsg-1ubuntu2) but 2:4.1.6+dfsg-1ubuntu2.14.04.2 is to be installed
Recommends: attr but it is not going to be installed
Recommends: samba-vfs-modules but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
执行 sudo apt-get update 后,再次执行安装命令 sudo apt-get install samba 还是报同样的错误。
因此尝试通过 aptitude 来安装 samba 。
首先安装 aptitude :sudo apt-get install aptitude
其次安装samba:sudo aptitude install samba,有如下提示:
samba : Depends: samba-common (= 2:4.1.6+dfsg-1ubuntu2) but 2:4.1.6+dfsg-1ubuntu2.14.04.2 is installed.
Depends: samba-common-bin (= 2:4.1.6+dfsg-1ubuntu2) but 2:4.1.6+dfsg-1ubuntu2.14.04.2 is installed.
Depends: samba-libs (= 2:4.1.6+dfsg-1ubuntu2) but 2:4.1.6+dfsg-1ubuntu2.14.04.2 is installed.
samba-vfs-modules : Depends: samba-libs (= 2:4.1.6+dfsg-1ubuntu2) but 2:4.1.6+dfsg-1ubuntu2.14.04.2 is installed.
samba-dsdb-modules : Depends: samba-libs (= 2:4.1.6+dfsg-1ubuntu2) but 2:4.1.6+dfsg-1ubuntu2.14.04.2 is installed.
The following actions will resolve these dependencies:
Keep the following packages at their current version:
1) samba [Not Installed]
2) samba-dsdb-modules [Not Installed]
3) samba-vfs-modules [Not Installed]
Accept this solution? [Y/n/q/?]
(提示的大概意思是samba依赖一定的包,他们都被安装了,但是版本不兼容,询问用户是否同意,若同意,则不按照samba,不同意则继续)
输入: n
然后会提示
The following actions will resolve these dependencies:
Downgrade the following packages:
1) libsmbclient [2:4.1.6+dfsg-1ubuntu2.14.04.2 (now) -> 2:4.1.6+dfsg-1ubuntu2 (trusty)]
2) python-samba [2:4.1.6+dfsg-1ubuntu2.14.04.2 (now) -> 2:4.1.6+dfsg-1ubuntu2 (trusty)]
3) samba-common [2:4.1.6+dfsg-1ubuntu2.14.04.2 (now) -> 2:4.1.6+dfsg-1ubuntu2 (trusty)]
4) samba-common-bin [2:4.1.6+dfsg-1ubuntu2.14.04.2 (now) -> 2:4.1.6+dfsg-1ubuntu2 (trusty)]
5) samba-libs [2:4.1.6+dfsg-1ubuntu2.14.04.2 (now) -> 2:4.1.6+dfsg-1ubuntu2 (trusty)]
6) smbclient [2:4.1.6+dfsg-1ubuntu2.14.04.2 (now) -> 2:4.1.6+dfsg-1ubuntu2 (trusty)]
Accept this solution? [Y/n/q/?]
(提示的大概意思就是要将所列出的软件包进行降版本,询问用户是否同意)
输入: Y
就会进行安装。
安装之后,怎么进行检测是否安装成功呢?
在终端下,输入 ”smb“ 让后 连按两下 ”Tab“ 键,显示:
smbcacls smbclient smbcquotas smbget smbspool smbtar smbtree 这些文件就表示安装成功。
第二步:修改配置
配置文件位于 “/etc/samba”文件夹下的 smb.conf 文件。
1、将该配置文件 备份一下,sudo cp smb.conf smb.conf.bkp
2、修改配置文件:sudo vim smb.conf 打开后,在末尾添加
[share]
comment=samba
path= /home/wwp/samba #共享文件夹的路径,可有自己设置
public=yes
creat mask=0755
directory mask=0755
forceuser=root
forcegroup=root
添加这几行代码的作用是,使得文件夹不需要密码就可以访问。