实验室的电脑安装的是Windows XP系统,我自己的笔记本安装的是ubuntu,之前苦于常常想操作电脑A的时候,却按了电脑B的键盘,让我浑身不自在,于是google网上的解决方法,发现了synergy这个好东西,通过共享设备的方式,两电脑共用同一套鼠标键盘,操作问题得到了解决!
然而,synergy两台电脑不能互相拷贝文件,作为一个弱弱的码农,目前还没有能力在synergy这个开源项目上扩展文件共享的功能,然而,笨人有笨人的方法,我决定给笔记本上个samba服务器,把自己的文件全部扔在服务器的共享目录下,windows端通过连接这个服务器,就可以同步修改这些文件,同时也就实现了文件共享,非常方便。
参考文章1,具体步骤如下:
前提条件:
你的Linux机器最好是有一个静态IP,当然是DHCP的话,也可以用,不过就不能使能“WINS”选项功能(后面会提到)。
(1)linux端:
先安装samba服务器
sudo apt-get install samba
然后确保samba当前是停止的
sudo /etc/init.d/samba stop
备份旧的配置
sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.template
创建新的配置
sudo touch /etc/samba/smb.conf
编辑此文件
sudo gedit /etc/samba/smb.conf
[global]
; General server settings
netbios name = YOUR_HOSTNAME
server string =
workgroup = YOUR_WORKGROUP
; announce version = 5.0
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_KEEPALIVE SO_RCVBUF=8192 SO_SNDBUF=8192
passdb backend = tdbsam
security = user
null passwords = true
username map = /etc/samba/smbusers
name resolve order = hosts wins bcast
wins support = yes
printing = CUPS
printcap name = CUPS
syslog = 1
syslog only = yes
; NOTE: If you need access to the user home directories uncomment the
; lines below and adjust the settings to your hearts content.
;[homes]
;valid users = %S
;create mode = 0600
;directory mode = 0755
;browseable = no
;read only = no
;veto files = /*.{*}/.*/mail/bin/
; NOTE: Only needed if you run samba as a primary domain controller.
; Not needed as this config doesn't cover that matter.
;[netlogon]
;path = /var/lib/samba/netlogon
;admin users = Administrator
;valid users = %U
;read only = no
; NOTE: Again - only needed if you're running a primary domain controller.
;[Profiles]
;path = /var/lib/samba/profiles
;valid users = %U
;create mode = 0600
;directory mode = 0700
;writeable = yes
;browseable = no
; NOTE: Inside this place you may build a printer driver repository for
; Windows - I'll cover this topic in another HOWTO.
[print$]
path = /var/lib/samba/printers
browseable = yes
guest ok = yes
read only = yes
write list = root
create mask = 0664
directory mask = 0775
[printers]
path = /tmp
printable = yes
guest ok = yes
browseable = no
; Uncomment if you need to share your CD-/DVD-ROM Drive
;[DVD-ROM Drive]
;path = /media/cdrom
;browseable = yes
;read only = yes
;guest ok = yes
[MyFiles]
path = /media/samba/
browseable = yes
read only = no
writeable = yes
guest ok = no
create mask = 0770
directory mask = 0770
; force user = YOUR_USERNAME
force group = YOUR_USERGROUP
用你自定义的主机名替换 "YOUR_HOSTNAME",中间不能有空格。
比如:
netbios name = LUOCANWEI_SERVER
-> workgroup = YOUR_WORKGROUP
用windows的工作组名称替换"YOUR_WORKGROUP" ,要确保跟连接的windows所在的工作组是一致的。
比如:
-> wins support = yes
如果你的Linux机器有一个静态IP地址,或者你不能配置你的路由/服务器提供一个固定的租用DHCP地址,这个配置选项配置为"no"。这样的话,你就不能使用到WINS的优势了。
-> [MyFiles]
这个是windows所看到的共享目录的名字,不更改也行,或者改为你自己想要的也行。不要超过31个字符,不要使用空格。
-> path = /media/samba/
共享文件存储的真实目录。如果linux上没有这个目录,就新建一个!
sudo mkdir /home/samba
windows端可以看到这个文件夹
-> writeable = yes
其他选项,如create mask, directory mask,force user,force group就参看链接2。
sudo /etc/init.d/samba start
若有错误,检查配置文件有没有不对的地方,如路径是不是不存在;
接着添加用户
sudo smbpasswd -L -a your_username
sudo smbpasswd -L -e your_username
比如:
sudo smbpasswd -L -a ray ;之后要求你输入和确认smb的登陆密码
到这里,服务器配置基本就欧了。
2) window端:
如果上面设置的"wins support" 是"no"的话,跳过下面这步设置:
控制面板->网络连接->LAN或高速Internet,找到你的LAN连接->右键属性->"TCP/IP" 协议->点击"属性" 按钮-> 点击 "高级..."->"WINS"-> "添加"->填入Linux的ip地址->"添加"->"启用 NetBIOS over TCP/IP"->重启Windows
接着,可以映射网络驱动器:
"我的电脑"-> "映射网络驱动器"->选择盘符->敲入 \\LUOCANWEI_SERVER\MyFiles
注意: 如果不是静态ip,LUOCANWEI_SERVER可能得改为乖乖每次敲打ip了,即敲入\\<ip-address>\MyFiles
完成。
参考:1 http://ubuntuforums.org/showthread.php?t=202605
2 http://www.1987.name/686.html
3 https://www.samba.org/samba/docs/man/manpages-3/smb.conf.5.html
5 http://zhidao.baidu.com/question/490153956.html
本文:http://blog.csdn.net/rayluoluo4/article/details/39718685