Difference between revisions of "Samba"

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
Jump to navigation Jump to search
m (→‎Commands: manpage links)
(extracted stuff to subpages; some tidying & updates)
 
Line 1: Line 1:
==Navigation==
+
<hide>
[[category:Samba]][[computing]]: [[software]]: [[Samba]]
+
[[page type::article]]
==Overview==
+
[[thing type::software]]
[[Samba]] is a program which allows "[[Network Neighborhood]]"-style communication between Windows and other platforms such as [[Linux]]. It is named after the [[SMB protocol]], which is what Windows uses for "Network Neighborhood" communication.
+
[[software type::server]]
 
+
[[category:software]]
==Commands==
+
</hide>
* '''User commands'''
+
==About==
** [[findsmb]]: lists Samba-connected machines by name, [[IP address]], [[Windows workgroup|workgroup]]; also shows [[master browser]] status
+
[[Samba]] is open-source server software which allows "[[Network Neighborhood]]"-style communication between [[Microsoft Windows]] and other [[operating system]]s such as [[Linux]]. It is named after the [[SMB protocol]], which is what Windows uses for "Network Neighborhood" communication.
*** DMB = [[Domain Master Browser]]
+
==Pages==
*** LMB = [[Local Master Browser]]
+
* {{l/sub|browser}}: debugging master/domain browser issues
** [[smbtree]] ({{link/manpage|smbtree|manpage}}): shows Samba servers and their shares in a hierarchical format
+
* {{l/sub|commands}} for interacting with Samba
** {{link/manpage|net}}
+
* {{l/sub|how-to}}
** [[nmblookup]] ({{link/manpage|nmblookup|manpage}})
+
* {{l/sub|printing}}: using Samba to serve shared printers
** [[smbclient]] ({{link/manpage|smbclient|manpage}})
 
** [[smbcontrol]] ({{link/manpage|smbcontrol|manpage}})
 
** [[smbpasswd]] ({{link/manpage|smbpasswd|manpage}})
 
** [[smbstatus]] ({{link/manpage|smbstatus|manpage}})
 
** [[testparm]] ({{link/manpage|testparm|manpage}})
 
* '''System commands''' (not usually run by the user)
 
** [[smbd]]: the Samba [[daemon]]
 
** [[nmbd]]: the NetBIOS name servernmbd [[daemon]]
 
 
 
==Related Articles==
 
* [[/browser]]: debugging master/domain browser issues
 
* [[/printing]]: using Samba to serve shared printers
 
 
* '''files'''
 
* '''files'''
 
** [[smb.conf]]: the Samba configuration file
 
** [[smb.conf]]: the Samba configuration file
Line 48: Line 36:
  
 
==How To==
 
==How To==
===Debug connection/access issues===
 
Samba maintains activity logs in /var/log/samba/. There seem to be two logs, log.nmbd and log.smbd; log.smbd generally has information about connections and access, while log.nmbd has more to to with network-name resolution. The nature of the log files is configurable somewhat through [[smb.conf]] (see '''log level''', among others). Use '''[[tail (command)|tail]] -f /var/log/samba/log.smbd''' (for example) to monitor a logfile in real-time.
 
 
===Restart the Samba Server===
 
If you have Fedora Core, there's a convenient little "services" application you can use to restart Samba and several dozen other services. For the rest of us, however, there's a command you have to execute from a root terminal.
 
 
On [[Ubuntu]], and probably other [[Debian]]-based systems:
 
[[sudo]] restart smbd
 
Prior to Ubuntu 10.04 or so (maybe 9?), this was:
 
[[sudo]] /etc/init.d/samba restart
 
On [[SuSE]] 10.0 and [[Fedora Core]] 4:
 
[[sudo]] /etc/init.d/smb restart
 
 
This will ask for a password; type in your password (not root's) unless you have reconfigured your sudo setup. (This assumes you have sudo privileges; if not, [[su]] to get root access and then type the rest of the command without the "sudo".)
 
 
On [[Red Hat Linux|Red Hat]], I'm told the command would be:
 
/sbin/samba restart
 
 
(Possibly substituting "smb" for "samba"; ls the directory in question to find a list of services.) This is the same general technique used for restarting services, which should itself probably be documented somewhere. (The Samba share configuration GUI program really ought to have a "restart Samba server" button, though, even if it does this automatically when you change parameters -- because there is no way to know if it is doing this otherwise.)
 
 
===Configure Samba for "guest" logins===
 
As most home operating systems are now moving towards requiring users to have login accounts, this is becoming less necessary -- but it is still useful under some circumstances (such as wanting to give access to Win9x machines with the login dialogue bypassed).
 
 
'''Step 1''' &ndash; adjust the configuration for [[smb.conf]]:
 
 
In the [global] section:
 
guest account = <u>guestuser</u>
 
guest ok = yes
 
security = share
 
 
...where <u>guestuser</u> should be a standard Linux user (typically "sambaguest") who has the necessary permissions on the target system for whatever sort of access you want to grant through the share. If the user doesn't have the correct permissions, client machines will probably be able to see the share but not to access anything inside it. Check /var/log/samba/ for log files which may help trace problems (the actual log filespecs are defined by the "log file =" parameter in [[smb.conf]]).
 
 
The following settings '''have not been tested successfully''' and aren't actually necessary, but can apparently be helpful if there are permissions conflicts (e.g. files created by <u>guestuser</u> can't be written or deleted by anyone else):
 
 
force group = <u>browsegroup</u>
 
force create mode = 0060
 
create mask = 0775
 
 
...where <u>browsegroup</u> is the groupname for users who should have access to shared stuff; I usually use "lanusers". "force group" may be unnecessary if <u>guestuser</u> is created as a member of <u>browsegroup</u> instead of its own private group:
 
 
{{linuxcmd|sudo}} {{linuxcmd|adduser}} --ingroup <u>browsegroup</u> --no-create-home <u>guestuser</u>
 
 
After editing and saving smb.conf. restart the Samba daemon for changes to take effect. ''Note for the future: it may actually be a better idea to leave off the --no-create-home option, because the <u>guestuser</u>'s home directory actually makes a very sensible place for folders to be shared from.''
 
 
'''Step 2''' &ndash; make sure the [[smbusers]] file exists, and has the <u>guestuser</u> account (typically "sambaguest") in it. The smbusers file lets you map {whatever login names remote systems (including Windows systems) might send} to the <u>guestuser</u> account, so such connections can be recognized as valid guest connections.
 
 
'''Step 3''' &ndash; make sure the Linux system has a user account for <u>guestuser</u>, and give that account any necessary access privileges.
 
 
'''A bit of explanation''': The "guest account" setting is the filesystem user which the Samba server uses for accessing files on its host system, regardless of what username is sent by remote systems. Files created on the Samba server using a "guest" connection will be owned by <u>guestuser</u> and <u>guestuser</u>'s primary group. If the "force group" setting is used, then the group ownership for those files will instead be <u>browsegroup</u>.
 
 
The actual names for <u>guestuser</u> and <u>browsegroup</u> are arbitrary; "sambaguest" and "lanusers" seem to work fine.
 
 
===Mount Remote Samba Shares on Local Filesystem===
 
Where the share to be mounted is "//beaker/My Documents", and assuming beaker is a [[Win98]] machine using share-mode security with no password:
 
* Short version --
 
mount -t cifs //BEAKER/MY\ DOCUMENTS /mnt/machines/beaker/My\ Documents -o sec=lanman,servername=BEAKER
 
* Long version, which will let you know if mount.cifs is not installed:
 
mount.cifs //beaker/MY\ DOCUMENTS /mnt/machines/beaker/My\ Documents --verbose -o sec=lanman,servername=BEAKER,guest
 
===Automatic resolution of Network Neighborhood names===
 
Some explanation, for technical purists:
 
* '''Problem''': How can we add [[Network Neighborhood]] machine names to the search space used by [[Linux]]'s [[domain name resolver]]?
 
* '''Justification''': This is needed so that commands which accept a domain name as input (e.g. ftp, ssh, mysql) can accept a machine name instead, removing the necessity to manually look up the machine's IP address. For example, I should be able to type '''ssh <u>machinename</u>''' instead of having to first look up <u>machinename</u>'s IP address via other methods, and then paste or retype that address (both methods prone to error) after the ssh command.
 
 
'''Note''': Under some circumstances, Samba appears to set itself up this way automatically, but results have been inconsistent.
 
 
I researched this extensively for many months and found many hideously complicated or otherwise inadequate solutions. It turns out, however, that there is quite a simple solution (which is probably trivially obvious to anyone with a solid understanding of how Linux networking is structured, and hence not worth mentioning):
 
* install [[winbind]]
 
** usually available in standard repositories; Ubuntu 6.06 and up have it
 
** this may not be necessary on some systems, e.g. Fedora 6 doesn't show winbind in its [[package repository]], but the next step makes things work anyway
 
* edit /etc/[[nsswitch.conf]]
 
** change the "hosts" line to include "wins" before "dns" (see the [[nsswitch.conf|examples]])
 
 
This tells Linux's [[domain name resolver]] to check [[WINS]] before it checks [[DNS]] when resolving domain names. No further action should be required (you don't even have to restart the networking daemon); test the change by trying to ping a local machine by name.
 
====related useful information====
 
The command '''{{linuxcmd|nmblookup}} <u>machinename</u>''' returns an IP address, as will '''{{linuxcmd|net}} lookup <u>machinename</u>'''. nmblookup apparently sends out a broadcast request ("anyone here named <u>machinename</u>?"), while net lookup checks a central list (presumably on the Samba master browser).
 
 
====explanations====
 
[[WINS]] is a method of [[domain name resolution]], as is [[DNS]]. [[WINS]] (a protocol) originally used [[NetBIOS]] (another, lower-level protocol), but more recently has switched to using [[TCP]].
 
 
 
==Links==
 
==Links==
 
===Official===
 
===Official===

Latest revision as of 18:54, 25 June 2018

About

Samba is open-source server software which allows "Network Neighborhood"-style communication between Microsoft Windows and other operating systems such as Linux. It is named after the SMB protocol, which is what Windows uses for "Network Neighborhood" communication.

Pages

Notes

as explained by user adaptr on #samba on freenode:

Each machine that participates in a netbios/smb network (or workgroup) is both client and server - it takes services and advertises them. Any machine at least advertises the MACHINE service – just its own netbios machine name with a specific SMB service type – so even if it's only trying to browse or auth to an SMB server, that client offers its own service data to what is known as the master browser.

user kukks adds:

To get more debug info from the cifs kernel module, use the following as root:

echo 7 > /proc/fs/cifs/cifsFYI

This will instruct cifs vfs to write more debug stuff to the kernel log.

can't browse into folders

The following lines in smb.conf fix a common problem where you can see folders underneath a share but can't browse into them (this may only be a problem if they are symbolic links):

# 2010-04-20 makes wide links work again
 # allows samba to show/include symbolic-linked folders and files:
 follow symlinks = yes
 # allows links to targets not within the shared folder
 wide links = yes
 # disable option incompatible with wide links
 unix extensions  = no

How To

Links

Official

Reference

Articles