Linux and Windows file sharing using Samba - Home Network

Write tutorials here
There are more tutorials here http://community.linuxmint.com/tutorial/welcome
Forum rules
Please don't add support questions to tutorials,start your own thread in the appropriate sub-forum instead. Before you post please read this
Post Reply
User avatar
orion2014
Level 1
Level 1
Posts: 21
Joined: Tue Dec 31, 2013 4:52 am
Location: New York, New York

Linux and Windows file sharing using Samba - Home Network

Post by orion2014 »

After I install any Linux distro, I like to setup a network share. I need all my machines to communicate, so after I update, then I setup my share. There's a wealth of information on this topic, some incomplete, and others a little to complicated and related to specific hardware or software. As with anything, I take bits and pieces, and through trial and error, create a method that works regardless of what hardware or software your running. I'm running Linux Mint 16 Cinnamon, and using Windows 7 - 8.1, for my examples. If you have a firewall setup on your Linux Machine you may need to disable until setup is complete, or allow incoming and outgoing.:mrgreen:

Before I proceed, some basic concepts you'll need to understand if you don't already. This setup works best with a Static IP address, a Dynamic IP address will cause you problems, because they change as devices come and go over your network, laptops, and other mobile devices, etc.

Static IP's - Stay the same
Dynamic IP's - Change
read = view without the ability to edit, move, delete, etc.
write = ability to view, edit, move, delete, etc.
yes - no
on - off
true - false
input - output
111's - 000's

First thing you need to install is Samba. I recommend using synaptic package manager, because it will provide other necessary dependencies and plug-ins. But, you can download from command line.

Code: Select all

sudo apt-get  install  samba samba-common
Necessary dependencies.

Code: Select all

sudo apt-get install python-glade2
Configuration tool.

Code: Select all

sudo apt-get install system-config-samba
Now you'll need a file manager that will assist with sharing using Samba. Nemo is the default file manager for Cinnamon, but there is Nautilus and Caja which is default for Mate. I use Nautilus and Nautilus-Dropbox. If you have a Dropbox account then I suggest downloading the Dropbox extention also. I recommend using Software Manager for download. But, you can use command line.

Code: Select all

sudo apt-get install nautilus
Next you'll need to create a Samba user and password. Replace username with your user name. You'll be asked to create a password, follow the prompt.

Note: Make password different from your root " sudo " password. This password will be your super user " su " password, and when running smb, or nmb, commands you'll be asked for your super user's " su " password, not your sudo " root " password.

Code: Select all

sudo smbpasswd -L -a username
This command will enable the user account you just added. Replace username with your user name that you just added.

Code: Select all

sudo smbpasswd -L -e username
Now you need to add a share or you can create a folder that you want to share. There's two ways to do this. You can right click on the folder and use the Share Option, or use the Samba Configuration Manager. Here's the thing, If you right click on the folder and use the Share Option, then it won't show up in your Samba Configuration Manager, but It's still part of your share, so if you used that method, then don't add it again with the configuration manager, It will create two shares of the same folder.

Now run this command to find your Samba Server.

Code: Select all

findsmb
This command will show all servers and shares

Code: Select all

smbclient -L your_linux_user_name
Next try to mount your shares, by opening your file manager and right clicking on " Connect to Server ".

Code: Select all

smb://your_ip_address
If your shares show up, then your good for now. Next you'll need to change some options in your smb.conf file.

Code: Select all

sudo gedit /etc/samba/smb.conf
You need to make some minor changes to Global Settings, only where highlighted in green. Example below.

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

[global]

## Browsing/Identification ###

# Windows Internet Name Serving Support Section:
# WINS Support - Tells the NMBD component of Samba to enable its WINS Server
# wins support = true

# WINS Server - Tells the NMBD components of Samba to be a WINS Client
# Note: Samba can be either a WINS Server, or a WINS Client, but NOT both
; wins server = w.x.y.z

# This will prevent nmbd to search for NetBIOS names through DNS.
dns proxy = true

Now for some network configurations on your Windows Machine.
Go to Network Sharing Settings
1. Click on your Network, to open Network Status Menu
2. Click on properties
3. Scroll to TCP/IPv4 and double-click
4. Click on Advanced
5. Choose Wins Tab
6. Add any IP Address that you want to communicate with your Windows Server, don't forget your Linux Machine.
7. If you've disabled NETBIOS settings, you need to enable NETBIOS over TCP/IP, at least.
Windows7 Professional
Windows7 Professional
Enabling Network Shares
1. Open Network Sharing Settings
2. Click on Advanced Sharing Settings
Under Home and Work, turn on everything that has on/off options, except password protected sharing. Turn that option off.

Now we need to add to your Network Share.
1. Open Libraries and choose folder/folders you want to add
2. Right click and scroll to share
3. Choose Specific People option
4. Hit arrow for drop-down menu
5. Choose everyone, then click add
6. By default only read access is granted, hit arrow and change to read/write.
NOTE: You'll need to reboot for registry changes

Ok, back to your Linux Machine, we need to grant permissions to users on your Samba Server.
1. Open Samba Configuration Settings
2. Click on Preferences, and Samba users
3. Click add users, you can leave the default user, Avahi
4. Add the Windows Computer name/names, and add password
5. Double-click on shared folder/folders
6. Click on access tab
7. Add check to box for the Avahi user you've just created.
You've just granted access permissions to your Windows user/users
NOTE: In the access settings you can choose everyone, or specific users. I recommend, specific users.

The moment of truth, your Linux Machine should be visible on your Windows system. Open file manager on Linux and click on " Connect to Server "

Code: Select all

smb://windows_machine_ip_address
Linux Mint 16 Cinnamon
Linux Mint 16 Cinnamon
Now, go to your Windows Machine, your Linux Machine should be visible under your networks tab. If not, open the " run " option.

Code: Select all

\\your_linux_machine_ip_address
If everything was done right, all your machines should be aware of each other. Once you get everything setup, you can " Map Network Drives " on your Windows Machine and use as a shared drive, backup drive or whatever, and share network drives across multiple devices. You can also " Bookmark " on your Linux Machine. Hope I've helped someone.

If you want to take it a step further and secure your network, check out this video from Nixie Pixel, she's awsome and imo, really hot;)
https://www.youtube.com/watch?v=-wUfzdi ... tube_gdata
Android Device - Astro File Manager
Android Device - Astro File Manager
If your running a rooted Android, root explorer application has added a feature where you can add tabs to your search, and there's a smb tab.

https://www.dropbox.com/s/epl3szlrudmohno/smb0.png

https://www.dropbox.com/s/jrdyi6itlou6xyy/smb1.png

For the really geeky, a list of commands that will give you a wealth of info on your network and shares. I suggest you type them in to get familiar with them and command line work. Enjoy

Code: Select all

smbclient -L username  [ Lists Domain, OS, Server, Computers, Shares, and Workgroup. ]

smbtree  [ Lists all your machines and shares ]

hostname   [ Your hostname ]

nmblookup -S WORKGROUP  [ Lists Netbios, and internal IP's ]

nmblookup -T WORKGROUP  [ List Netbios, and IP for any machines that are shariing services. ]

testparm -s   [ Lists Server Role, Shares and their attributes, also Checks services. ]

testparm  [ Same as above command, but gives you the option to display more info. ]

  
[ These commands only work if you used share options in your file manager " right clicked " ]

net usershare list   [ Lists just shares ]
net usershare info   [ Information about your shares ]

Linux Mint 19.2
Cinnamon 4.2.4
4.15.0-60-generic
Intel Core i3-6100U CPU@ 2.30GHz x 2
Memory 8GB
SSD 250GB
Intel Corporation Skylake GT2 [HD Graphics 520]

Post Reply

Return to “Tutorials”