Install Samba Server on Ubuntu 7.10 (Gutsy Gibbon)

If you want to share files between your Ubuntu and Windows computers,
your best option is to use Samba file sharing.
To install, first open a terminal window and enter the following command:

sudo apt-get install samba smbfs

 


We've got samba installed, but now we'll need to configure it to make it accessible.

Run the following command to open the configuration file, substituting your editor of
choice:

sudo gedit /etc/samba/smb.conf

 


Find this section in the file:

####### Authentication #######

# "security = user" is always a good idea. This will require a Unix account
# in this server for every user accessing the server. See
# /usr/share/doc/samba-doc/htmldocs/Samba-HOWTO-Collection/ServerType.html
# in the samba-doc package for details.
;  security = user

 

 

 

 



Uncomment the security line, and add another line to make it look like this:

security = user
username map = /etc/samba/smbusers

 

 

This will set Samba to use the smbusers file for looking up the user list.

Create a Samba User

There are two steps to creating a user. First we'll run the smbpasswd utility to create a
samba password for the user.

sudo smbpasswd -a <username>



When you get an error:
"Failed to modify password entry for user <username>".
You have to add this username also in Linux "Users and Groups".

Next, we'll add that username to the smbusers file.

sudo gedit /etc/samba/smbusers



Add in the following line, substituting the username with the one you want to give
access to.
The format is <ubuntuusername> = "<samba username>". 

You can use a different samba user name to map to an ubuntu account, but that's
not really necessary right now.

<username> = "<username>"



Now you can create samba shares and give access to the users that you listed here.


Share Ubuntu Home Directories using Samba

Samba Server allows you to share the home directories of users automatically.
This can be useful so that you don't have to manually create every share for every user.

First, make sure that you've installed Samba server.

To share the home directories, open up smb.conf with the following command:

sudo gedit /etc/samba/smb.conf


Find this section of the file, and make it match the following:

#======================= Share Definitions =======================

# Un-comment the following (and tweak the other settings below to suit)
# to enable the default home directory shares. This will share each
# user's home directory as \\server\username
[homes]
comment = Home Directories
browseable = yes

# By default, \\server\username shares can be connected to by anyone
# with access to the samba server. Un-comment the following parameter
# to make sure that only "username" can connect to \\server\username
valid users = %S

# By default, the home directories are exported read-only. Change next
# parameter to 'yes' if you want to be able to write to them.
writable = yes





















Save the edited file

sudo testparm
sudo /etc/init.d/samba restart



Now you should be able to map a drive on windows using the following share format:
\\ubuntumachine\username


For example, if the Ubuntu machine is named ubuntuserv, and the username is john,
your share path would be \\ubuntuserv\john

How to share group folders with read only permission
(Authentication=Yes)

sudo mkdir /home/group  
sudo chmod 777 /home/group/
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_backup
gksudo gedit /etc/samba/smb.conf








Find this line

...
; security = user
...








Replace with the following lines

security = user   
username map = /etc/samba/smbusers







Append the following lines at the end of file

[Group]
comment = Group Folder
path = /home/group
public = yes
writable = no
valid users = system_username1 system_username2
create mask = 0700
directory mask = 0700
force user = nobody
force group = nogroup














Or if you want other network users to be able to edit to the folder then change:

writable = yes




Save the edited file

sudo testparm
sudo /etc/init.d/samba restart




How to share public folders with read only or read/write
permissions (Authentication=Yes)

sudo mkdir /home/public
sudo chmod 777 /home/public/
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_backup
gksudo gedit /etc/samba/smb.conf






Find this line


...
; security = user
...





Replace with the following lines

security = user  
username map = /etc/samba/smbusers





Then follow either 1. or 2.

1. Save the edited file.

sudo testparm
sudo /etc/init.d/samba restart




1. Right click the folder and select 'Share folder'. Then change 'Do not share' to share
with the network you would like.

1. In Share Properties note the read box. If you want other network users to be able
to edit to the folder un-tick this.

Or

2. Append the following lines at the end of file

[public]
comment = Public Folder
path = /home/public
public = yes writable = yes
create mask = 0777
directory mask = 0777
force user = nobody
force group = nogroup











2. Or if you want other network users to be able to edit to the folder


writable = yes




2. Save the edited file

sudo testparm
sudo /etc/init.d/samba restart




How to share public folders with read only or read/write
permissions (Authentication=No)

sudo mkdir /home/public sudo
chmod 777 /home/public/
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_backup
gksudo gedit /etc/samba/smb.conf






Find this line

...
; security = user
...






Replace with the following line

security = share





Then follow either 1. or 2.

1. Save the edited file.

sudo testparm sudo /etc/init.d/samba restart



1. Right click the folder and select 'Share folder'. Then change 'Do not share' to share
with the network you would like.

1. In Share Properties note the read box.
If you want other network users to be able to edit to the folder un-tick this.

OR

2. Append the following lines at the end of /etc/samba/smb.conf (for a read-only folder)

[public]
comment = Public Folder
path = /home/public
public = yes
writable = no
create mask = 0777
directory mask = 0777
force user = nobody
force group = nogroup












2. Or if you want other network users to be able to edit to the folder

writable = yes





2. Save the edited file

sudo testparm
sudo /etc/init.d/samba restart





How to print on remote Ubuntu machine via samba

Make sure your Ubuntu printers are configured properly.

sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.backup
gedit /etc/samba/smb.conf





Find the following lines

...
# printing = cups
# printcap name = cups
...






and uncomment them.

printing = cups
printcap name = cups




Restart cups server

sudo /etc/init.d/cupsys restart



Now printers working on your Ubuntu machine should be acessible via samba.