Sharing folders from Linux with Samba

July 27th, 2017

Installing it is fairly easy. Open the terminal and execute this command:

sudo apt install samba

When that is done, a little configurating is needed to share the folders you want. This is done by modifying the configuration file which is found here:

/etc/samba/smb.conf

You can open it with whatever you want, I personally use nano. To open it with that, type:

sudo nano /etc/samba/smb.conf

It will open inside the terminal. Use arrowkeys and page up/down to navigate. Go to the bottom of the file to add a new share.

[www] (name of the share, will be shown when you add it)
path = /var/www (the path to the folder you want to share)
browseable = yes (decide if it’s visible)
valid users = greitnok (who can use it. “invalid users” does the opposite)
read only = no (allows users to write to directory/files)

There’s a lot of other things as well, you can find them here:

https://www.samba.org/samba/docs/man/manpages-3/smb.conf.5.html

To save the file, hit Ctrl + X, and hit Y  to save, and then enter without changing the name. Restart samba with this command for the changes to take effect:

sudo service smbd restart

It should now be available. Both with \\<host ip> and \\<hostname>

From Linux, you’ll need to use smb://<ip or hostname>, unless you use some GUI.