1、安装: Centos 5.5下安装samba,具体步骤如下:
[root@bogon ~]# rpm -q samba
Package samba is not installed
[root@bogon ~]# yum -y install samba
[root@bogon ~]# yum install samba-mount
[root@bogon ~]# yum install system-config-samba
使用yum命令安装samba,加入-y参数,如遇询问自动选择y,全自动下载并安装samba
2、检查samba服务包的安装情况,会显示类似如下两个包:
[root@bogon win]# rpm -qa|grep samba
samba-3.0.33-3.29.el5_6.2
samba-common-3.0.33-3.29.el5_6.2
samba-client-3.0.33-3.29.el5_6.2
system-config-samba-1.2.41-5.el5
3、查看samba安装位置:
[root@bogon ~]# whereis samba
samba:/etc/samba /usr/lib/samba/ usr/share/samba
/usr/share/man/man7/samba.7.gz
4、查看Samba服务运行状态:
[root@bogon ~]# service smb status
smbd is stopped
nmbd is stopped
5、启动Samba服务:
[root@bogon ~]# service smb start
Starting SMB services: [ OK ]
Starting NMB services: [ OK ]
也可以设置系统启动时,自动启动Samba服务
root@bogon ~]# chkconfig --level 2345 smb on
6、将windows下的文件共享给linux
(1)将windows中的文件(夹)的属性设置为共享,如:E:/test/
(2)通常用smbmount加载文件,在centos5中,该命令被mount.cifs取代
(In Red Hat Enterprise Linux 5 smbmount command has been replaced by mount.cifs)
挂载步骤如下:
[root@bogon ~]# mkdir /mnt/win/
[root@bogon ~]# mount.cifs //192.168.1.105/test /mnt/win/ -o username=root,password=111111
(mount.cifs //windows IP/files linux dir o- username , password)
或者用下面命令:
[root@bogon ~]# mount.cifs //192.168.1.105/test /mnt/win/
Password:
[root@bogon ~]#
(3)查看共享的文件:
[root@bogon ~]# cd /mnt/win/
[root@bogon win]# ls
1.txt
(4)卸载共享的文件
[root@bogon win]# cd
[root@bogon ~]# umount //192.168.1.105/test
注意,卸载的时候,一定要从共享的目录中退出,否则将无法卸载
7、使用sbmclient命令来共享windows文件
命令格式:
操作步骤如下:
(1)将windows中的文件(夹)的属性设置为共享,如:E:/test/
(2) [root@bogon test]# smbclient //192.168.1.105/test -U administrator
Password:
Domain=[CHINA-133A9A16A] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]
smb: \>
验证用户名密码即可,到这一步表示成功登录smb
(3) 可用ls命令查看当前目录下的共享文件:
smb: \> ls
. D 0 Thu May 5 11:32:12 2011
.. D 0 Thu May 5 11:32:12 2011
1.txt A 103 Thu May 5 13:42:26 2011
33745 blocks of size 2097152. 27637 blocks available
smb: \>
(4) 用get命令可从服务器上下载某文件:
smb:\> get file1 file2(从服务器上下载file1,以file2为名保存在本地
smb: \> get 1.txt /root/test/test.txt
getting file \1.txt of size 103 as /root/test/test.txt (4.4 kb/s) (average 4.4 kb/s)
smb: \>
(5)exit命令可退出smb服务器