访问一次后,mary的用户和密码被系统记住了,如果在访问会直接跳到下面的界面。要想让目录可以读写,要同时满足两条件,一个是smb.conf配置权限设置,一个是目录权限设置
[root@localhost samba]# ls -ld /usr/somewhere/shared/ //查看权限,其他用户是不可读写的
[root@localhost samba]# chmod o+rw /usr/somewhere/shared/ //设置其它用户的权限为读写
[root@localhost samba]# ls -ld /usr/somewhere/shared/ //查看修改的权限,其它用户是可读可写可执行
drwxr-xrwx 2 root root 4096 4月 12 22:19 /usr/somewhere/shared/
//用fred用户登录的,如果以前做的是服务器记住访问用户,当重启Linux系统后就用fred用户登录
//可读可写可了
练习security=user安全级别。设一个简单的共享。 编辑samba主配置文件/etc/samba/smb.conf [root@localhost root]# cd /etc/samba //切换到/etc/samba目录
[root@localhost samba]# mv smb.conf smb.conf.bak //将smb.conf改名为smb.conf.bak,进行备份
[root@localhost samba]# grep -v \
//去掉smb.conf.bak文件以“#”开头的说明信息,显现剩下的内容重定向导到当前目录的smb.conf文件中
[root@localhost samba]# vim smb.conf //打开编辑smb.conf文件 [redhat] //共享目录名为redhat
comment=redhat is share directory //说明redhat是一个共享目录 path=/mnt/share //共享目录的路径
valid users = redhat @root //只用redhat用户及root超级用户可以访问 wirte list = redhat //只有redhat用户有写的权限 writable = yes //说明目录是可写的 public = no //是否是公用的 printable = yes //是否可以打印
create mode = 0664 //创建文件后,文件的权限 directory mode = 0775 //创建目录后,目录的权限
然后保存退出。
[root@localhost samba]# useradd redhat //创建一个redhat用户
[root@localhost samba]# smbpasswd -a redhat
//对redhat添加smb密码,与passwd redhat没有关系呀,这个是登陆本机用户密码。 [root@localhost samba]#smbpasswd -a root //给root用户添加smb密码。
[root@localhost samba]# mkdir -p /mnt/share //创建路径目录,如果/mnt不存在,同时创建。 [root@localhost samba]#chmod 0777 /mnt/share
//给用户添加,当前用户,组,及其他用户,对目录/mnt/share有读写执行的权限。 [root@localhost samba]# service smb restart //重启smb服务,让配置文件重新加载
最好在win7进行访问,win+R(开始--运行):\\\\IP(linux下的IP地址)回车。 用户输入:redhat
密码:***(你设置的redhat的smb密码)
打完收工!!!