<a href="http://www.51testing.com/?145083/action_viewspace_itemid_65596.html">原文連結</a>
<a href="http://www.cnblogs.com/wangkangluo1/archive/2012/06/15/2550821.html#smbclient">samba client</a>
<a href="http://www.cnblogs.com/wangkangluo1/archive/2012/06/15/2550821.html#ubunt">ubuntu</a>
<a href="http://www.cnblogs.com/wangkangluo1/archive/2012/06/15/2550821.html#redhalt">redhat</a>
<a href="http://www.cnblogs.com/wangkangluo1/archive/2012/06/15/2550821.html#ubuntu_gui">ubuntu gui tools</a>
smbclient -L 198.168.0.1
2,在security=share模式下通路一個匿名可以通路的目錄
smbclient //192.168.0.1/目錄名
3,像FTP用戶端一樣使用smbclient
smbclient //192.168.0.1/tmp -U username%password
4,例,建立一個共享檔案夾
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
5,除了使用smbclient,還可以通過mount和smbcount挂載遠端共享檔案夾
mount -t smbfs -o username=administrator,password=123456 //192.168.0.1/tmp /mnt/tmp
# mount -t smbfs -o username="administrator",password="" //192.168.1.100/cp /mnt/ntfs
提示出錯:
查資料後,說smbfs改為cifs了,是以要用下面的方法:
# mount -t cifs -o username="administrator",password="" //192.168.1.101/cp /mnt/ntfs
成功!!
smbmount //192.168.0.1/tmp /mnt/tmp -o username=administrator
通路目錄:
# sudo apt-get insall samba
# sudo apt-get install smbfs
二. 建立共享目錄:
# mkdir /home/willis/share
# sodu chmod 777 /home/willis/share
三. 建立Samba配置檔案:
1. 儲存現有的配置檔案
# sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.bak
2. 建立新的Samba配置檔案
# sodu vim /etc/samba/smb.conf
; ############### smb.conf #######################
[global]
workgroup = MYGROUP
; 安全模式, 我們設定最低安全級别
security = share
; 是否允許guest使用者通路
guest ōk = yes
[share]
; 共享檔案夾路徑
path = /home/willis/share
; 讀權限
browseable = yes
; 寫權限
writeable = yes
# testparm
五. 重新開機Samba服務
# /etc/init.d/smbd restart
六. 退出重新登陸或者重新開機機器
七. 測試登陸
# smbclient -L //localhost/share
從遠端的機子上測試:
# smbclient //<samba_server_ip>/share
成功咯! :-)
八. 參考資料
一、區域網路内的 Linux 伺服器上操作步驟:
1、安裝samba(CentOS Linux):
yum install samba system-config-samba samba-client samba-common
2、建立www賬号
/usr/sbin/groupadd www
/usr/sbin/useradd -g www www
mkdir -p /data0/knose/
chmod 777 /data0/knose/
mkdir -p /data0/htdocs/
chown -R www:www /data0/htdocs/
chmod 777 /data0/htdocs/
cat /etc/passwd | mksmbpasswd.sh> /etc/samba/smbpasswd
3、建立samba配置檔案
mv -f /etc/samba/smb.conf /etc/samba/smb.conf.bak
vi /etc/samba/smb.conf
輸入以下内容:
引用
server string = Samba Server
security = user
encrypt passwords = yes
smb passwd file = /etc/samba/smbpasswd
[knose]
workgroup = root
netbios name = root
path = /data0/knose
browseable = yes
writeable = yes
[web]
workgroup = www
netbios name = www
path = /data0/htdocs
4、為samba使用者www、root設立一個密碼:
smbpasswd -a www
smbpasswd -a root
5、啟動samba:
/sbin/service smb start
二、區域網路内的 Windows 伺服器上操作步驟:
<a></a>
1、Windows 上通路 samba,在“我的電腦”中輸入:
\\xxx.xxx.xxx.xxx\
2、Windows 斷開 samba 共享連接配接,在【開始】→【運作】→【cmd】回車中輸入:
net use * /del
3、将 samba 共享的 Linux 目錄,映射成 Windows 的一個驅動器盤符:

三、跨平台C/C++代碼編譯、調試:
用 Windows 下的編輯器編寫、修改跨平台的C/C++代碼,儲存後,無需複制到其他地方,即可同時用 Windows 下的 Visual Studio,Linux 下的 g++、gcc、gdb,編譯、調試程式了。
注意:在samba共享的驅動器上執行“.bat”批處理腳本,會導緻 Windows 藍屏,這一點需要注意。
First thing we need to do is to install samba, go to Software center in Ubuntu and search for samba then install the package. If you want to install it via terminal then copy this command :
Now install the graphical interface System-config samba
Now we will try for example to share the directory /home/pirat9/share folder to do that,
First open GUI samba server configuration tool by going to System–> Administration–>Samba
Add the folder you want to share and setup the permissions access.
Now right click on the folder directory you want to share and open the share options
Then select share this folder
If you want to setup folder access permissions, right click on the folder and open properties (See screenshot bellow)
If you want to add a password to the user: open a terminal and type the command :
and then type your password.
Now the configuration is done.
Now lets try to check if we can for example connect from a windows machine. To do that
In a windows machine go to start –>Run and type :
ip or hostname
You will be asked to insert the user and password
Check the share folder
And is done.
完