Thursday, 11 October 2012

Mount Windows share (smb) on Linux system

What:

Windows and Linux platforms

Problem:

Mount windows share on linux machine via command line

Solution:

mount -t cifs //<server>/share /mnt/dir -ouser=<username>
mount.cifs //<server>/share /mnt/dir -ouser=<username>

To automatically mount on boot, edit /etc/fstab, on Ubuntu first user get's uid=1000, check yours with
echo $UID
When share is not secured:
//<server>/share /mnt/dir cifs uid=1000 0 0
When share is secured, keep in mind that password is in plain text
//<server>/share /mnt/dir cifs username=,password=,uid=1000 0 0
Preferred way is to save username and password in a file and then specify a path with credentials option.

The format of the file /root/.smb-login is:
username=<username>
password=<password>
domain=<domain>
 //<server>/share /mnt/dir cifs auto,uid=1000,gid=1000,file_mode=0664,dir_mode=0775, credentials=/root/.smb-login 0 0

No comments:

Post a Comment