Samba
Since I get a lot of requests from people who would like a page on how to set up and use Samba in Ubuntu, here it is. The information here worked successfully for people a couple of years ago, and unless the method has changed, it should still work. I have no way of testing it since I don’t have Windows on any of the computers here. My email is in the menu bar at the top of the page if I’m horribly wrong and you want to set me straight. (:
Install Samba
- Open a terminal window and type this command to install Samba and smbfs:
-
sudo apt-get install samba smbfs
Configure Samba
- Type this command in a terminal window to open the Samba configuration file:
-
gksudo gedit /etc/samba/smb.conf
- Find this section in the file:
- Uncomment the security line by removing the semi-colon and the space.
- Add this line beneath the now uncommented security line:
- Your changes should match this example:
- Save and close 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
username map = /etc/samba/smbusers
####### 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 username map = /etc/samba/smbusers
Create a Samba user
- Type this command in a terminal window to assign a Samba password to the user:
- It will ask for your Ubuntu password.
- Enter your Ubuntu password.
- It will then ask for a new password.
- Enter the password you’d like to use for Samba.
sudo smbpasswd -a USERNAME
Note: Replace USERNAME with your Ubuntu username.
Add the user to Samba
- Type this command to edit the Samba users file:
- Add the following line to the file, replacing UBUNTU_USERNAME with your Ubuntu username and WINDOWS_USERNAME with the Windows username who will be accessing the Ubuntu machine.
gksudo gedit /etc/samba/smbusers
UBUNTU_USERNAME = WINDOWS_USERNAME
Now you can create samba shares and give access to the users that you listed here.
Share your Ubuntu home directory
- To share your Ubuntu home directory and make it so the Windows user has the power to write to the Ubuntu drive, type this command in a terminal window to configure Samba:
- Find this section of the file, and make it match the following:
gksudo gedit /etc/samba/smb.conf
#======================= 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
Restart Samba
- Type this command in a terminal window to restart Samba to use the new configuration:
-
sudo /etc/init.d/smb restart
Set up the Samba share in Windows
- When mapping a drive in Windows to access the share, use the following format:
-
\\UBUNTU_COMPUTER_NAME\UBUNTU_USERNAME
- For example, if your Ubuntu computer’s name is MyUbuntuComputer and your Ubuntu username is LittleOldMe, then you would use this information to map the Windows drive:
-
\\MyUbuntuComputer\LittleOldMe
Connect to the Samba share in Windows
When Windows asks to connect to the Ubuntu share, enter your Ubuntu username and your Samba password to connect.
Obligatory Happy Ending
And they all lived happily ever after. The end.
Comment: