apt install samba winbind

Reload services

systemctl reload-or-restart smbd winbind

Sometimes it is better to force a restart all services because of those damn caches:

systemctl restart smbd winbind

Stops samba services:

systemctl reload-or-restart smbd nmbd winbind

smbcontrol – send messages to smbd, nmbd or winbindd processes

smbcontrol all reload-config
smbcontrol smbd reload-config
smbcontrol nmbd reload-config
smbcontrol winbind reload-config

SMB path

A smb URL:


Mount a CIFS share in /etc/fstab

//server/share /mnt/share cifs ro,credentials=/root/smbcredentials,iocharset=utf8,vers=3.0 0 0

With /root/smbcredentials looking like this:


Doing this, all files on this share will appear as owned by root.


Create homedirs on the fly

Don’t use PAM !! obey pam restrictions = no is the default, so nothing will go through pam (and thus pam_mkhomedir is useless…).

But since the pam module calls mkhomedir_helper, we can just call it directly:

## Global
        template homedir = /other/path/%D/%U
## Share
        browseable = No
        comment = users home folder
        create mask = 0700
        directory mask = 0700
        path = /SAN300/homes/%U
        read only = No
        root preexec = /usr/sbin/mkhomedir_helper %U
        valid users = %S

And the GPO is there: User Configuration/Preferences/Windows Settings/Drive Maps/ with:


Improve throughput

server multi channel support = yesglobal
deadtime = 30global
use sendfile = yesshare
min receivefile size = 16384global
aio read size = 1
aio write size = 1


testparm – check an smb.conf configuration file for internal correctness

-s|--suppress-promptWithout this option, testparm will prompt for a carriage return after printing the service names and before dumping the service definitions.
-v|--verboseIf this option is specified, testparm will also output all options that were not used in smb.conf(5) and are thus set to their defaults.
--show-all-parametersShow the parameters, type, possible values.
--parameter-name parameternameDumps the named parameter. If no section-name is set the view is limited by default to the global section. It is also possible to dump a parametrical option. Therefore the option has to be separated by a colon from the parametername.
testparm -v
testparm --show-all-parameters | grep 'server multi channel support'

smbstatus – report on current Samba connections

check currently opend files:

# smbstatus

net – Tool for administration of Samba and remote CIFS servers

net ads join -U administrator

samba-tool – Main Samba administration tool (>4.15.0 only)

samba-tool domain join mydomain.lan MEMBER -U domainadmin@domain.lan



smbpasswd – change a user’s SMB password

add/remove user in the SMB database:

# smbpasswd -a technician
New SMB password:
Retype new SMB password:
Added user technician.
# smbpasswd -x technician
Deleted user technician.

pdbedit – manage the SAM database (Database of Samba Users)

-L|–listThis option lists all the user accounts present in the users database.
List users
pdbedit -L


wbinfo – Query information from winbind daemon

-p|–pingCheck whether winbindd(8) is still alive. Prints out either ‘succeeded’ or ‘failed’.
-P|–ping-dcIssue a no-effect command to our DC. This checks if our secure channel connection to our domain controller is still alive.
-t|–check-secretVerify that the workstation trust account created when the Samba server is added to the Windows NT domain is working.
-u|–domain-usersThis option will list all users available in the Windows NT domain for which the winbindd(8) daemon is operating in.
-g|–domain-groupsThis option will list all groups available in the Windows NT domain for which the samba(7) daemon is operating in.
-a|--authenticate username%passwordAttempt to authenticate a user via winbindd(8). This checks both authentication methods and reports its results.
-i, --user-info=USERGet user info
wbinfo --ping-i
wbinfo --ping-dc
sudo wbinfo --check-secret
wbinfo --domain-users
wbinfo --domain-groups
wbinfo -a testuser

Clear winbind cache

systemctl stop smbd nmbd winbind
net cache flush
cd /var/lib/samba/
mkdir old && mv *.tdb old/.
systemctl start smbd nmbd winbind

idmap backends

idmap_rid Backend

sssd – System Security Services Daemon



smbcacls – Set or get ACLs on an NT file or directory names

smbcacls //bigdaddy/Music enigma -U sambauser

getcifsacl – Userspace helper to display an ACL in a security descriptor for Common Internet File System (CIFS)

getcifsacl ./file

NT Domain Member

Join domain

Make sure there’s a line in /etc/hosts: memberservername.domain.ext memberservername

smb.conf examples

Here is an example of a working and clean smb.conf.

Do not forget to replace all DOMAIN shit, including in the idmap config.
Also, the default idmap config (*) must be last !

#======================= Global Settings =======================


### Browsing/Identification ###

        workgroup = DOMAIN
        security = ADS
        realm = DOMAIN.LOCAL

        map acl inherit = Yes
        # the next line is only required on Samba versions less than 4.9.0
        store dos attributes = yes

        disable netbios = yes

#### Debugging/Accounting ####

        log file = /var/log/samba/log.%m
        max log size = 1000
        # Enable this for debug:
        #log level = 3 passdb:5 auth:5

####### Authentication #######

        server role = member server
        local master = no
        domain master = no
        preferred master = no
############ Winbind ############

        winbind refresh tickets = Yes
        winbind use default domain = Yes
        # For testing purposes only:
        #winbind enum users = yes
        #winbind enum groups = yes

        idmap config DOMAIN : backend = rid
        idmap config DOMAIN : range = 20000-90000000
        idmap config * : backend = tdb
        idmap config * : range = 3000-7999

#### Disable printing completely ####

        load printers = no
        printing = bsd
        printcap name = /dev/null
        disable spoolss = yes

#======================= Share Definitions =======================
        comment = Add a useful comment here
        path = /mnt/storage/shared
        valid users = +"Domain Users"
        force group = "Domain Users"
        read only = No
        create mask = 0660
        directory mask = 0770
        force create mode = 0660
        force directory mode = 0770
        vfs objects = acl_xattr
        comment = Add a useful comment here
        create mask = 0660
        directory mask = 0770
        force create mode = 0660
        force directory mode = 0770
        path = /mnt/storage/shared
        read only = No
        valid users = "+Domain Users"
        vfs objects = acl_xattr catia fruit streams_xattr
        fruit:delete_empty_adfiles = yes
        fruit:wipe_intentionally_left_blank_rfork = yes
        fruit:posix_rename = yes
        fruit:veto_appledouble = no
        #fruit:metadata = stream


Concerning the + & and @ symbols:

A name starting with a ‘@’ is interpreted as an NIS netgroup first (if your system supports NIS), and then as a UNIX group if the name was not found in the NIS netgroup database.
A name starting with ‘+’ is interpreted only by looking in the UNIX group database via the NSS getgrnam() interface. A name starting with ‘&’ is interpreted only by looking in the NIS netgroup database (this requires NIS to be working on your system). The characters ‘+’ and ‘&’ may be used at the start of the name in either order so the value +&group means check the UNIX group database, followed by the NIS netgroup database, and the value &+group means check the NIS netgroup database, followed by the UNIX group database (the same as the ‘@’ prefix).


To be sorted

sudo apt install samba winbind libpam-winbind libnss-winbind krb5-config samba-dsdb-modules samba-vfs-modules

Append the winbind entry to the following databases in the /etc/nsswitch.conf (passwd and group)

sudo smbcontrol all reload-config

getent passwd DOMAIN\\leo