To add a share that is accessible by all users.
Create the directory for sharing the files and change the owner to the users group.
sudo mkdir -p /srv/samba/
sudo chown -R root:users /srv/samba/ [brusgroup][financial]
sudo chmod -R ug+rwx,o+rx-w /srv/samba/
Adding and managing users
eg. for group users
and user mattu
:
useradd mattu -m -G users
passwd mattu
sudo usermod -aG users mattu
Set a password for mattu
passwd mattu
Enter the password for the new user
Now add the user to the Samba user database.
sudo smbpasswd -a mattu
Enter the password for the new user
Edit the /etc/samba/smb.conf file
sudo vi /etc/samba/smb.conf
add the following lines and save the file
[allusers]
comment = All Users
path = /srv/samba/allusers/
valid users = @users
force group = users
create mask = 0660
directory mask = 0771
writable = yes
If all users shall be able to read and write to their home directories via Samba, edit the /etc/samba/smb.conf file and remove all lines. In vim:
- Type
gg
to move the cursor to the first line of the file, if it is not already there.
- Type
dG
to delete all the lines.
Now you should be able to log in from your Windows workstation with the file explorer using username ruchi and the chosen password and store files on the ubuntu server either in ruchi's home directory or in the public shared directory.
[global]
workgroup = WORKGROUP
#netbios name = [FRODO]
passdb backend = tdbsam
printcap name = cups
add user script = /usr/sbin/useradd -m %u
delete user script = /usr/sbin/userdel -r %u
add group script = /usr/sbin/groupadd %g
delete group script = /usr/sbin/groupdel %g
add user to group script = /usr/sbin/groupmod -A %u %g
delete user from group script = /usr/sbin/groupmod -R %u %g
add machine script = /usr/sbin/useradd -s /bin/false -d /var/lib/nobody %u
# Note: The following specifies the default logon script.
# Per user logon scripts can be specified in the user account using pdbedit
logon script = scripts\logon.bat
# This sets the default profile path. Set per user paths with pdbedit
logon path = \\%L\Profiles\%U
logon drive = H:
logon home = \\%L\%U
domain logons = Yes
os level = 35
preferred master = Yes
domain master = Yes
#[deprecated thus change
#idmap uid = 15000-20000
#idmap gid = 15000-20000
#]
#[
idmap config * : backend = tdb
idmap config * : range = 10001-20000
idmap config DOMAIN : backend = rid
idmap config DOMAIN : range = 10000-20000
idmap config DOMAIN : base_rid = 0
#]
printing = cups
Example 2.8. Engineering Office smb.conf (shares and services)
[homes]
comment = Home Directories
valid users = %S
read only = No
browseable = No
# Printing auto-share (makes printers available thru CUPS)
[printers]
comment = All Printers
path = /var/spool/samba
printer admin = root, maryo
create mask = 0600
guest ok = Yes
printable = Yes
browseable = No
[print$]
comment = Printer Drivers Share
path = /var/lib/samba/drivers
write list = maryo, root
printer admin = maryo, root
# Needed to support domain logons
[netlogon]
comment = Network Logon Service
path = /var/lib/samba/netlogon
admin users = root, maryo
guest ok = Yes
browseable = No
# For profiles to work, create a user directory under the path
# shown. i.e., mkdir -p /var/lib/samba/profiles/maryo
[Profiles]
comment = Roaming Profile Share
path = /var/lib/samba/profiles
read only = No
profile acls = Yes