8 Ways To Mount SMBfs (SAMBA FILE SYSTEM) In Linux.

Sep 8, 2009

How to Mount smbfs (SAMBA file system) permanently in Linux.In this post I am going to give some examples how to do SMB (Server Message Block) mounts..

Type1 : Listing SMB shared folder through command prompt

#smbclient –L ipadd –U username

Here –L will specify listing of SMB share for the server with ipadd

Or

#smbclient //192.168.0.1/share1 –U username

Example :

#smbclient –L 192.168.0.1 –U root

Type2 : Mounting SMB share on local folder by using smbmount command

#smbmount //ipadd/sharename /mountpoint –o username=userid,workgroup=workgroupname

Example :

#smbmount //192.168.0.1/share1 /mnt –o username=steev,workgroup=test

Type3 : Mounting SMB share by using mount command

#mount –t smbfs ipadd:/sharename /mountpoint –o username=userid,workgroup=workgroupname

Or

#mount –t smbfs //ipadd/sharename /mountpoint –o username=userid,workgroup=workgroupname

Example :

#mount –t smbfs 192.168.0.1:/share1 /mnt –o username=surendra,workgroup=test

Type4 : Mounting CIFS (Common Internet File System) is nothing but a advanced SMB file system implementation which support RAP (Remote Access Protocol)

#mount –t cifs ipadd:/sharename /mountpoint –o username=userid,workgroup=workgroupname

Example :

#mount –t cifs 192.168.0.1:/share1 /test –o username=Surendra,workgroup=test

Type5 : All the above commands will ask password to display/mount the share name, however we can specify the password in command itself as below

#mount -t smbfs -o username=userid,workgroup=workgroupname,password=XXXXX //ipadd/sharepoint /mountpoint/

Example :

#mount –t smbfs –o username=Surendra,workgroup=test,password=xylBJRS8 //192.168.0.1/share1 /test

Type6 : Mounting permanently by editing /etc/fstab file, below is the fstab file entry example

#vi /etc/fstab//192.168.0.1/share1 /test smbfs rw,user,username=surendra,password=xylBJRS8 0 0

Save and exit the file and conform that you edited fstab file properly. By below commands

#mount –a

This command should not throw any error,

#df –H

This command should show mount from 192.168.0.1 server

 

列出某个IP地址所提供的共享文件夹
smbclient -L 198.168.0.1 -U username%password

像FTP客户端一样使用smbclient
smbclient //192.168.0.1/tmp -U username%password
执行smbclient命令成功后,进入smbclient环境,出现提示符: smb:/> 这时输入?会看到支持的命令
这里有许多命令和ftp命令相似,如cd 、lcd、get、megt、put、mput等。通过这些命令,我们可以访问远程主机的共享资源。

直接一次性使用smbclient命令
smbclient -c "ls" //192.168.0.1/tmp -U username%password

smbclient //192.168.0.1/tmp -U username%password
smb:/>ls
功能一样的

例,创建一个共享文件夹
smbclient -c "mkdir share1" //192.168.0.1/tmp -U username%password
如果用户共享//192.168.0.1/tmp的方式是只读的,会提示
NT_STATUS_ACCESS_DENIED making remote directory /share1

除了使用smbclient,还可以通过mount和smbcount挂载远程共享文件夹
挂载 mount -t cifs -o username=administrator,password=123456 //192.168.0.1/tmp /mnt/tmp
取消挂载 umount /mnt/tmp

使用smbfs将远程共享挂载到本地并正确设置中文

 

 

您需要安装smbfs软件包

 


使用mount命令完成,如(必须给出具体的共享名,可以通过前面介绍的smbclient获得共享名):
# mount -o guest -t smbfs //192.168.0.20/linux /mnt/win_share

 

需要登录时:
# mount -t smbfs -o username=tridge,password=foobar //fjall/test /data/test

另外,为了能正确显示中文,以utf8为locale的用户(如果使用UbuntuFedora,默认就是utf8的locale)加入以下选项:codepage=cp936iocharset=utf8,即mount命令写为:
# mount -o guest,iocharset=utf8,codepage=cp936 -t smbfs //192.168.0.20/linux /mnt/win_share

这所以这样写,是因为远端使用的编码是cp936,而本地使用的是utf8

以gbk为locale的用户则

# mount -o guest,iocharset=cp936,codepage=cp936 -t smbfs //192.168.0.20/linux /mnt/win_share

这样写的原因是远端和本地都是cp936

最新文章

  1. PHP 类型判断和NULL,空值检查
  2. java访问数据库的sql
  3. [BZOJ 1483][HNOI 2009]梦幻补丁(有序表启发式合并)
  4. STL学习笔记序言
  5. java计时代码
  6. Visual Leak Detector 2.2.3 Visual C++内存检测工具
  7. JS 动态显示 获取下拉框的多个值
  8. Qt Add ons Modules(听说QtSystem有接口可以获取 imei号)
  9. PPPoE Server Under Ubuntu/Debian
  10. Codeforces 193D Two Segments 解题报告
  11. libusb-win32 在visual studio2008中成功编译回忆录
  12. Java中的多线程Demo
  13. Python爬虫(十二)_XPath与lxml类库
  14. 不为人知的网络编程(八):从数据传输层深度解密HTTP
  15. JAVA的第一次作业
  16. 【Zookeeper系列】ZooKeeper安装配置(转)
  17. linux重启查看日志及历史记录 查询原因
  18. JQuery获取touchstart,touchmove,touchend坐标
  19. vue学习一:新建或打开vue项目(vue-cli2)
  20. spring boot 与 filter

热门文章

  1. Vue 子组件与子组件之间传值
  2. React Native细节知识点总结<一>
  3. Kubernetes-kubectl The connection to the server localhost:8080 was refused -did you specify
  4. 【学习笔记】XPath定位总结
  5. Linux安装sdkman
  6. public static void main(String[] args) 是什么意思?
  7. RestTemplateBuilder类
  8. Linux安装git (git-2.11.0)
  9. 深入理解MySQL索引原理和实现——为什么索引可以加速查询?
  10. VMware Conveter Standalone agent 安装时出现Error 29190错误的解决办法