4

My servers are Ubuntu. I want to know whether Samba is installed accidentally or not. Is the following command correct?

It seems that Samba isn't installed.

$ samba --version
The program 'samba' is currently not installed. You can install it by typing:

$ ps -ef | grep smb
(empty)
  • The second command is correct, the first is not strictly correct since there is no binary called samba - use smbd --version instead. – LSerni May 26 '17 at 13:15
7

It certainly looks likely it's not installed. Try checking with your package manager as to what's installed as a final check. But I would say it looks like it is not installed.

You could also do a search for the executable by using

find / -executable -name samba
  • Programs can be installed without using a packet manager. – FMaz May 26 '17 at 11:00
  • I know. That's why I suggested it as part of a process of checking points after the one the poster had done themselves. – ISMSDEV May 26 '17 at 11:11
  • 3
    This command will not find the Samba executable, which is called smbd. It will detect the -x directories that Samba uses or used, even after Samba has been uninstalled (e.g. /var/lib/samba). – LSerni May 26 '17 at 13:01
8

I feel that the other answers, while undoubtedly useful, do not answer exactly what you asked for... that is, whether Samba is running, but either whether Samba was installed at some time (by looking at files on disk, which might be left over) or whether Samba is installed with the system's knowledge, which might not be always the case.

dpkg will not tell you whether Samba is installed; it will tell you whether it was installed using dpkg/apt or not. If you install Samba from scratch via a tarball, for example, the whole Ubuntu installation system will truthfully tell you that it's not aware of Samba ever having been installed... even if Samba is up and running.

To verify that samba is installed you do indeed try to run it:

smbd -V

If installed (even if it is not running), it will report its version.

The same check can be done with the client part of the Samba suite, which is not necessarily installed with the server:

smbclient --version

For the file system support, just in case, you do mount.cifs -V instead. Strictly speaking this is CIFS support, not Samba.

To know whether the Samba program is running, you can either check the running processes of the Samba suite (smbd, nmbd, winbind):

sudo ps waux | grep "[sn]mbd"

This will return either nothing if the program is not running, or a list of the processes part of the Samba suite:

root     23942  0.0  0.3 299100 15176 ?        Ss   May24   0:00 /usr/sbin/smbd -D
root     23943  0.0  0.1 298532  4744 ?        S    May24   0:00 /usr/sbin/smbd -D
root     23944  0.0  0.1 298556  7408 ?        S    May24   0:00 /usr/sbin/smbd -D
root     23946  0.0  0.2 299092  9504 ?        S    May24   0:00 /usr/sbin/smbd -D

Or you can verify whether they're listening to ports:

sudo netstat -nap | grep "[sn]mbd"

This will return nothing if the processes are not running, or it will tell you which ports are they listening to:

tcp        0      0 192.168.2.200:445       0.0.0.0:*               LISTEN      23942/smbd
tcp        0      0 192.168.2.200:139       0.0.0.0:*               LISTEN      23942/smbd

Above, for example, my smbd is listening on ALL (0.0.0.0) remote addresses.

Another way is to check whether anything is listening in Samba's place on TCP ports 139 and 445:

sudo fuser -n tcp 139

This will return either nothing (program not running) or the PID of the running process:

139/tcp:             23942
6

You can check with $ dpkg -L samba

1

To check if the package samba is installed on Ubuntu , you can use:

dpkg -s samba | grep Status

To find out all files provided by the package samba:

dpkg -L samba

Using apt:

apt-cache policy samba

Sample output:

samba:
Installed: (none)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.