Here's my smb.conf file. Whats wrong with it?
There are a couple of things you need to know about the samba configuration file. Well, i'm lying. There is a lot you need to know (I had to spend a couple of days reading through the manual). But to sum everything up it depends on where you are sharing the folder from.
If the folder is inside your home folder, you can simply right click the folder, select sharing and follow the options provided. Easy solution.
If the folder is outside your home folder, for example, in /media/username/movies
, the fastest way of sharing the folder is to put in the [global]
section in the smb.conf file force user = USERNAME
where username is your user or the owner of the shared folder. This has several security implications but is nonetheless, the fastest way of sharing if you are on a LAN and trust the rest of the group.
If you already did the 2 mentioned above for each case, you then need to check if you are actually on the same LAN network (Check IP class), same subnet and same workgroup. For the latter, you can change the workgroup in the smb.conf under the workgroup =
variable.
If you already have done all the steps mentioned above then we proceed to see if the permissions are correct:
- Does the share folder actually have the username as owner?
- Does the share folder have read/write/execute permissions?
- Can you access the shared folder from another Ubuntu PC or another version of Windows?
Depending on this answers you can most likely know where the problem is coming from. Most of the time, it is, in my case, a Windows 8 problem. Windows 8 has several options that you need to change in the "Network & Sharing" menu in order to see the LAN correctly (This applies not only to seeing Ubuntu shared resources but also other Windows versions like XP and 7).
There are tools to simplify the sharing of folders outside the home folder like the system-config-samba
package, but they help to a degree. You can also check man smb.conf
to see a lot of information regarding this file, specially the part about security which I would recommend reading this https://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/ServerType.html#id2559439 which is better for the eye than the man pages. Specially the part about security = user
.
Here is an example of a working samba share /media/cyrex/movies
working for another Windows 7, Windows 8 and 2 Ubuntu PCs in the same IP range and Workgroup:
[global]
workgroup = WORKGROUP
server string = %h server (Samba, Ubuntu)
dns proxy = no
force user = cyrex
log file = /var/log/samba/log.%m
max log size = 1000
syslog = 0
panic action = /usr/share/samba/panic-action %d
encrypt passwords = true
obey pam restrictions = yes
unix password sync = yes
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
pam password change = yes
map to guest = bad user
usershare allow guests = yes
[printers]
comment = All Printers
browseable = no
path = /var/spool/samba
printable = yes
create mask = 0700
[print$]
comment = Printer Drivers
path = /var/lib/samba/printers
[movies]
path = /media/cyrex/titan/movies
browseable = yes
guest ok = yes
The only lines I added where the force user = cyrex
in the [global]
section and the section for the [movies]
which was made by the system-config-samba
app but you can also do it by hand.
After that just sudo service smbd restart
and wait a couple of seconds/minutes for the switch/router/network devices to update.