挂载命令
sudo apt-get install cifs-utils
sudo mount -t cifs -o username=sss,password=ss123,vers=2.0 //192.16.1.231/public/data /root/data
命令参数说明:
-t 挂载的文件系统类型;
cifs是公共的或开放的SMB协议版本,并由Microsoft使用;
-o 允许使用分隔符选项
“用户名”就是你windows的用户名,“密码”就是windows对应的密码;
ip地址就是windows的ip,注意前面2个斜杠不要打错了;
“linux”为windows下共享的目录
/mnt/win为linux /mnt下的win目录,win目录是自己mkdir自己手动创建,或另外命名都可以;
如果不想让别人看到你的密码:可以把"password=密码"删除,命令如下:
取消挂载的操作
[root@localhost /]# umount /mnt/test/
umount: /mnt/test:目标忙。
(有些情况下通过 lsof(8) 或 fuser(1) 可以
找到有关使用该设备的进程的有用信息)
[root@localhost /]# lsof
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1001/gvfs
Output information may be incomplete.
^C
您在 /var/spool/mail/root 中有邮件
[root@localhost /]# fuser -mv /mnt/test/
用户 进程号 权限 命令
/mnt/test: root kernel mount /mnt/test
root 105548 ..c.. bash
[root@localhost /]# kill -9 105548
您在 /var/spool/mail/root 中有邮件
[root@localhost /]# ^C
[root@localhost /]# fuser -mv /mnt/test/
用户 进程号 权限 命令
/mnt/test: root kernel mount /mnt/test
您在 /var/spool/mail/root 中有邮件
[root@localhost /]# umount /mnt/test/
可以使用 fuser -km /nfsdata 进行 kill 进程。
开机自启动和一次性挂载命令
windows主机ip:10.17.128.101
共享文件夹:shared
用户名:nobody
密码:123456
挂载到Linux中的目录/mnt/shared中:
mount -t cifs -o username=nobody,password=123456
//10.17.128.101/shared /mnt/shared这种命令只是单次的,重启之后会失效,想要开机自动挂载,有两种方法:
第一种:
vi /etc/rc.d/rc.local
在末尾添加:
mount -t cifs -o username=nobody,password=123456
//10.17.128.101/shared /mnt/shared保存后使之为可执行文件:
chmod +x /etc/rc.d/rc.local