I'm a CentOS 6
User so I tried this method on CentOS 6
Install samba using
[root@server ~]# yum install samba
Query for confirm
[root@server ~]# rpm -qa samba
samba-3.5.10-125.el6.i686
Create a Samba User.
[root@server ~]# useradd sambashare
Now create samba password for username sambashare using smbpasswd command.
[root@server ~]# smbpasswd -a sambashare
New SMB password:
Retype new SMB password:
Added user sambashare.
Create a samba share directory
[root@server ~]# mkdir /share
change the ownership for the share folder
[root@server ~]# chown -R sambashare:sambashare /share/
Open the file /etc/samba/smb.conf
and add the below lines.
[share]
comment = Share
path = /share
writable = yes
valid users = sambashare
Start samba service
[root@server ~]# service smb restart
Shutting down SMB services: [ OK ]
Starting SMB services: [ OK ]
Check your configuration by using testparm
command
.
.
[share]
comment = share
path = /share
valid users = sambashare
read only = No
In windows system type this in run
![enter image description here](../../I/static/images/d953ff0f6beee2dcf1315d8edc7edb5ae3f5ad130f2ce7c4b4783e119c32fb64.jpg)
Now enter samba username and password
![enter image description here](../../I/static/images/a2819a0c91a7ee31062b7a5cc13c2b21c6ec99649a9971ee2ea9fe82ccd0064c.jpg)
You are done
![enter image description here](../../I/static/images/b3c3214f4a1a8ffff5f4e3b5ed46e04ad998da4a1a841d5ad23a7835f1a0cf92.jpg)
@max, Thanks for your great answers. I know samba can work with Windows. But it still needs human being involvements when copying a file. As my script will run on one linux and the machine has installed samba, how can I let the one script do the copying work? It seems that I had better mount the Windows disk to Linux, then I can access it in Linux. Can samba do this? – Alex – 2013-03-11T04:50:53.693
Yes, Samba can do this. Even better, you don't need to mount the Windows share at all. You can use
smbclient
to connect to the Windows share, copy a file and disconnect. I edited my answer, take a look at it. – jaume – 2013-03-11T10:30:06.160You're welcome, I'm glad I could help. – jaume – 2013-03-11T13:27:31.017
1Especially the
-c
option is worth using in simple cases. On my machine the password comes as a bare argument (without any option). And besides - I prefer to keep the credentials away from commandline readers (usingps
or[h]top
, for example), by calling-U $(cat .username) $(cat .password)
. – Tomasz Gandor – 2014-06-18T14:47:43.127