[iyunv@localhost ~]# cd /abc/
[iyunv@localhost abc]# touch f1.public
[iyunv@localhost abc]# cd /zhangsan/
[iyunv@localhost zhangsan]# touch f1.zhangsan
[iyunv@localhost zhangsan]# cd /lisi/
[iyunv@localhost lisi]# touch f1.lisi
建立smb账号库
[iyunv@localhost lisi]# smbpasswd -a lisi
New SMB password:
Retype new SMB password:
Added user lisi.
[iyunv@localhost lisi]# smbpasswd -a zhangsan
New SMB password:
Retype new SMB password:
Added user zhangsan.
重新启动smb服务
[iyunv@localhost lisi]# service smb restart
关闭 SMB 服务: [确定]
关闭 NMB 服务: [确定]
启动 SMB 服务: [确定]
启动 NMB 服务: [确定]
测试:
linux客户端测试:
[iyunv@localhost ~]# smbclient //192.168.20.20/smbzs -U zhangsan
Password:
Domain=[LOCALHOST] OS=[Unix] Server=[Samba 3.0.33-3.14.el5]
smb: \> dir
. D 0 Mon Aug 20 00:45:38 2012
.. D 0 Mon Aug 20 00:27:53 2012
f1.zhangsan 0 Mon Aug 20 00:32:09 2012
111 D 0 Mon Aug 20 00:45:36 2012
新建 文本文档.txt A 0 Sun Sep 16 15:41:35 2012
38752 blocks of size 262144. 25762 blocks available
smb: \> !dir
01 abcd b d3 f1 inittab install.log.syslog nn passwd qq3 useradd.sh
abc anaconda-ks.cfg d2 Desktop f3 install.log mbox nxl qq2 test.sh
smb: \> dir
. D 0 Mon Aug 20 00:45:38 2012
.. D 0 Mon Aug 20 00:27:53 2012
f1.zhangsan 0 Mon Aug 20 00:32:09 2012
111 D 0 Mon Aug 20 00:45:36 2012
新建 文本文档.txt A 0 Sun Sep 16 15:41:35 2012
38752 blocks of size 262144. 25762 blocks available
smb: \> put install.log
putting file install.log as \install.log (637.2 kb/s) (average 637.2 kb/s)
smb: \> dir
. D 0 Mon Aug 20 00:59:16 2012
.. D 0 Mon Aug 20 00:27:53 2012
f1.zhangsan 0 Mon Aug 20 00:32:09 2012
111 D 0 Mon Aug 20 00:45:36 2012
新建 文本文档.txt A 0 Sun Sep 16 15:41:35 2012
install.log A 35236 Mon Aug 20 00:59:17 2012
38752 blocks of size 262144. 25762 blocks available
smb: \> mget f1.zhangsan
Get file f1.zhangsan? y
getting file \f1.zhangsan of size 0 as f1.zhangsan (0.0 kb/s) (average 0.0 kb/s)
smb: \> !dir
01 abcd b d3 f1 f3 install.log mbox nxl qq2 test.sh
abc anaconda-ks.cfg d2 Desktop f1.zhangsan inittab install.log.syslog nn passwd qq3 useradd.sh
smb: \>
挂载到本地
建立挂载点
[iyunv@localhost ~]# mkdir /mnt/smb
[iyunv@localhost ~]# mount -t cifs //192.168.20.20/smbzs /mnt/smb -o username=zhangsan
Password:
查看
[iyunv@localhost ~]# mount
/dev/sda2 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/hdc on /mnt/cdrom type iso9660 (ro)
//192.168.20.20/smbzs on /mnt/smb type cifs (rw,mand)
进入目录查看信息
[iyunv@localhost ~]# cd /mnt/smb/
[iyunv@localhost smb]# ll
总计 36
drwxr-xr-x 2 502 502 0 08-20 00:45 111
-rw-r--r-- 1 root root 0 08-20 00:32 f1.zhangsan
-rwxr--r-- 1 502 502 35236 08-20 00:59 install.log
-rwxr--r-- 1 502 502 0 2012-09-16 新建 文本文档.txt
开机自启动挂载
[iyunv@localhost ~]# vim /etc/fstab
//192.168.20.20/smbzs /mnt/smb cifs defaults,username=zhangsan%123 0 0
[iyunv@localhost ~]# mount -a
[iyunv@localhost ~]# mount
/dev/sda2 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/hdc on /mnt/cdrom type iso9660 (ro)
//192.168.20.20/smbzs on /mnt/smb type cifs (rw,mand)
编辑fstab
[iyunv@localhost nfs]# vim /etc/fstab
192.168.20.20:/public /mnt/nfs nfs ro,soft,intr 0 0
挂载
[iyunv@localhost ~]# mount –a
查看挂载信息
[iyunv@localhost ~]# mount
/dev/sda2 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/hdc on /mnt/cdrom type iso9660 (ro)
192.168.20.20:/public on /mnt/nfs type nfs (ro,soft,intr,addr=192.168.20.20)
自动挂载
查看自动挂载服务已经安装
[iyunv@localhost ~]# rpm -qa |grep auto
autofs-5.0.1-0.rc2.131.el5
编辑脚本
[iyunv@localhost ~]# vim /etc/auto.master
/mnt/nfs /etc/auto.nfs --timeout=30
产生/etc/auto.nfs文件
[iyunv@localhost ~]# cp -p /etc/auto.misc /etc/auto.nfs
编辑auto.nfs
[iyunv@localhost ~]# vim /etc/auto.nfs
server -ro,soft,intr 192.168.20.20:/public
重启autofs
[iyunv@localhost ~]# service autofs restart
停止 automount: [确定]
启动 automount: [确定]
进入挂载目录查看挂载信息
[iyunv@localhost nfs]# cd server
[iyunv@localhost server]# mount
/dev/sda2 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/hdc on /mnt/cdrom type iso9660 (ro)
192.168.20.20:/public on /mnt/nfs/server type nfs (ro,soft,intr,addr=192.168.20.20)
[iyunv@localhost server]# mount
/dev/sda2 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/hdc on /mnt/cdrom type iso9660 (ro)
192.168.20.20:/public on /mnt/nfs/server type nfs (ro,soft,intr,addr=192.168.20.20)
30秒后将自动断开
[iyunv@localhost ~]# mount
/dev/sda2 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/hdc on /mnt/cdrom type iso9660 (ro)