How To: Create a Ubuntu Samba Network Share

Setting up a Ubuntu media server is pretty useless unless you know how to create a samba network share directory. Here's a quick, uncomplicated and brief how to guide that is as quick as 1, 2, 3 ... 4, 5, 6, 7, 8.

After you've logged into your Ubuntu box please proceed to use all commands as root (precede each command with 'sudo' or use 'sudo su').

1. Install Samba

sudo aptitude update
sudo aptitude install samba

2. Set a password for your user in Samba

sudo smbpasswd -a <user_name>

Note: Samba uses a separate set of passwords than the standard Linux system accounts (stored in /etc/samba/smbpasswd), so you'll need to create a Samba password for yourself. This tutorial implies that you will use your own user and it does not cover situations involving other users passwords, groups, etc...

Note: Remember that your user must have permission to write and edit the folder you want to share.

sudo chown <user_name> /var/opt/folder/anotherfolder

3. Create a directory to be shared

mkdir /home/<user_name>/<folder_name>

4. Make a safe backup copy of the original smb.conf file to your home folder, in case you make an error

sudo cp /etc/samba/smb.conf ~

5. Edit the file '/etc/samba/smb.conf'

sudo vim /etc/samba/smb.conf

Once 'smb.conf' has loaded, add this to the very end of the file:

[<share_name>]
  comment = share description
  path = share path i.e. /home/<user_name>/<folder_name>

  available = yes
  browseable = yes
  guest ok = yes
  writeable = yes
  create mask = 0755


6. Restart Samba

sudo restart smbd

7. Once Samba has restarted, use this command to check your smb.conf for any syntax errors

testparm

8. To access your network share use your username (<user_name>) and password through the path 'smb://<HOST_IP_OR_NAME>/<folder_name>/' (Linux users) or '\\<HOST_IP_OR_NAME>\<folder_name>\' (Windows users). Note that the '<folder_name>' value is passed in '[<share_name>]', in other words, the share name you entered in "/etc/samba/smb.conf".

Note: The default user group of samba is "WORKGROUP".

No comments:

Post a Comment