Basic Samba Setup on Ubuntu 8.04 Hardy Heron

By Jonathan Moeller - Last updated: Friday, May 9, 2008 - Save & Share - 53 Comments

The recent post about Ubuntu 8.04 hosing a Samba install has gotten quite a few hits, so it seems that I’m not the only one who’s having this problem. For those having Samba problems with Ubuntu 8.04 (after an upgrade from a previous version), I suspect the best approach would be to uninstall Samba entirely, reinstall it, and redo the settings from scratch. Along those lines, here are instructions on how to install Samba on a Ubuntu 8.04 machine, and how to set up basic file sharing on a folder for a single user.

First, make your way to a Terminal window, and install Samba:

sudo apt-get install samba

This will download the Samba files from the Ubuntu repositories and install them. Once Samba is installed, you’ll need to create a Samba password for yourself:

sudo smbpasswd -a USERNAME

(USERNAME, of course, being your username.)

Type a password of appropriate strength twice (utilizing uppercase, lowercase, numbers, and punctuation). Once that’s done, you’ll need to edit the /etc/samba/smb.conf file, Samba’s configuration file. Start by making a folder named ‘test’ on your Desktop; we’ll use that for the shared folder. Next, make a safe backup copy of the original smb.conf file to your Desktop, in case you make a typo:

sudo cp /etc/samba/smb.conf ~/Desktop

Now use your text editor of choice to edit smb.conf:

sudo gedit /etc/samba/smb.conf

(Gedit will probably be the easiest due to the GUI; but you can use vi or emacs just as readily.)

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

[test]
path = /home/USERNAME/Desktop/test
available = yes
valid users = USERNAME
read only = no
browsable = yes
public = yes
writable = yes


(Note that there should be no spaces between the lines; depending on your web browser, it might render this post with extra spaces between the lines.)

This will share the test folder on your Desktop, and give your username, and only your username, permissions to both read and write. Save the changes you have made to smb.conf, exit the text editor, and restart Samba:

sudo /etc/init.d/samba restart

Once Samba has restarted, you’ll need to test it. Try accessing the shared folder from another computer on your LAN (to start, it would probably be easiest to access it by IP address). If you can read/write to the folder after entering your username and password, you have set up Samba correctly.
-JM


Posted in Linux • • Top Of Page

53 Responses to “Basic Samba Setup on Ubuntu 8.04 Hardy Heron”

Comment from Jonathan Moeller
Time May 9, 2008 at 8:06 pm

This is true. There’s no Nautilus on the server edition, though. And as for myself, I would prefer to know how to *really* do it, as opposed to relying on the GUI.

Comment from neonard0
Time May 22, 2008 at 9:19 pm

I support you answer. Samba is really helpfull in my server edition.
Thanks

Comment from Jonathan Moeller
Time May 22, 2008 at 9:42 pm

neonard0:

I’m glad it was helpful.

Comment from FranzyPants
Time May 24, 2008 at 8:05 pm

I’m having a bit of an issue using Samba, it seems I do not have the proper permission to save the ‘smb.conf’ file. Do I need to be logged in as the root user?

Comment from Jonathan Moeller
Time May 24, 2008 at 8:18 pm

FranzyPants:

You do need root-level permissions to edit smb.conf. However, logging in as root is bad security practice, so I’d suggest using the sudo command in conjunction with your text editor of choice:

sudo gedit /etc/samba/smb.conf

Be sure to make a backup copy of smb.conf before editing.

Comment from EastBayAnt
Time May 30, 2008 at 9:33 pm

Thank you so much. Now I’ve just got to figure out how to make Ubuntu auto-mount the secondary drive in my machine for automatic sharing…

Comment from chris
Time June 3, 2008 at 7:49 pm

I cannot get samba shares working – I have followed and repeated the above instructions 3x but winxp still cannot access the samba shares.
Winxp can see the linux box ( \\linuxbox ) but will not accept the username/password to go in any further.

Comment from Jonathan Moeller
Time June 3, 2008 at 7:54 pm

You may have to authenticate via this format:

linuxbox\username

password

Comment from chris
Time June 3, 2008 at 8:01 pm

Tried that – no go
Cant access the shared linuxbox printer from winxp either

Also I have a shared drive in the winxp pc – linuxbox cannot even see the winxp pc

Comment from Jonathan Moeller
Time June 4, 2008 at 7:42 am

In that case I’d suggest double-checking the smbpasswd command, and maybe creating a new user and testing with that. From what I’ve seen, that error usually crops up due to smbpasswd problems.

Comment from chris
Time June 4, 2008 at 2:45 pm

Ok getting more weird by the minute.
Winxp can now get into samba ( linuxbox) but the shares dont show,
Only showing are printers and a folder called “shared” which is NOT one of my shared folders… (I dont have a share called “shared”)
BUT – If i browse the network from the linuxbox to \\linuxbox ( browsing itself on the network ) all the intended shares are present and working.
Linuxbox can however access a winxp shared folder now so at least I can push data one way. :)

thanks for your patience

chris

Comment from Jonathan Moeller
Time June 4, 2008 at 3:29 pm

Now that is strange. I’d almost guess that one (or both) of the computer’s firewalls are interfering with the process. I would also double-check the settings for the individual shared folders in the smb.conf file.

The trouble with diagnosing this sort of thing is that there are quite literally hundreds of variables that can affect it.

Comment from chris
Time June 4, 2008 at 8:53 pm

As usual, when something seems totally impossible, there is a simple ( if not totally understandable) answer.
I have 3 PC’s on my LAN. Two run Ubuntu 8.04, one runs winxp.
The winxp PC was showing me the wrong samba shares at //linuxbox
It was actually showing me //IBM2/[shares] ( the 3rd pc )
Even though the path in winxp was reading //linuxbox/shared – it was actually //IBM2/shared
So running cat /etc/hosts on both linux pcs proves that they DO have different hostnames , nothing wrong there.
Therefore I have no idea why or how windows could get confused over this….
Shutting down IBM2 allows Winxp to access the samba shares of //linuxbox
Which leads me to thinking its something to do with my router/switch

anyway, thanks for your help,
back to the twighlight zone……..

chris

Comment from Jonathan Moeller
Time June 4, 2008 at 9:13 pm

Excellent! I believe Sherlock Holmes was right when he said that the most complex problems always have the simplest solutions.

It sounds like a DNS problem, then. I suspect then that the culprit is either your router/switch, or whatever device serves as your LAN’s DNS server. It appears that the DNS server is send the hostname to the wrong IP.

Comment from bizo
Time June 11, 2008 at 11:29 am

great tutorial !! much better than GUI nonsense.. thx !@

Comment from Jonathan Moeller
Time June 11, 2008 at 11:39 am

Glad it helped. And it’s good to see someone else appreciates the command line!

Comment from Jerry
Time June 19, 2008 at 2:45 pm

I’ve tried my best… I’ve followed all the instructions and when I sudo gedit /ect/samba/smb.conf the file it brings up is blank. I’ve tried edit smb.conf several ways and it tells me I do not have the permission to save the file. HELP!!!!!

Comment from Jonathan Moeller
Time June 19, 2008 at 2:58 pm

Jerry:

It could be a typo. If you’ve been typing /ect/samba/smb.conf, that would do it, since it’s supposed to be /etc/samba/smb.conf. It’s also possible that either the permissions or the ownership of your smb.conf file is messed up.

Comment from clutch
Time June 20, 2008 at 6:53 pm

I have been through many of these sites and followed all kinds of directions and no matter what I try I keep getting an “access denied” error when I try to mount my shares. I can’t even see them in the network section of nautilus. All this started after switching to hardy (1 upgrade and 1 clean install on 2 systems).

Comment from Philip Wess
Time June 25, 2008 at 7:23 pm

This worked perfectly for me. I had a fresh install of ubuntu. I was trying to see my Ubuntu drive with XP and all the other fixes I tried did not work. Thanks

Comment from Ian
Time June 26, 2008 at 10:29 am

Using the GUI may not be so good particularly on Xubuntu as nautilus does not have a shared option. I’ll start again on my ubuntu and xubuntu machines and see how it goes. On the ubuntu hardy machine I’m not able to see any network files in nautilus. Regards Ian.

Comment from Ian
Time June 26, 2008 at 1:36 pm

Hi, it ran out of locks. I’ll try again in a day or two. regards Ian.

stanley82@Ian-desktop:~$ sudo apt-get install samba
[sudo] password for stanley82:
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages were automatically installed and are no longer required:
linux-headers-2.6.24-16 linux-headers-2.6.24-16-generic
Use ‘apt-get autoremove’ to remove them.
The following extra packages will be installed:
samba-common
Suggested packages:
openbsd-inetd inet-superserver smbldap-tools
The following NEW packages will be installed:
samba samba-common
0 upgraded, 2 newly installed, 0 to remove and 25 not upgraded.
E: Could not get lock /var/cache/apt/archives/lock – open (11 Resource temporarily unavailable)
E: Unable to lock the download directory
stanley82@Ian-desktop:~$ sudo smbpasswd -a stanley82
sudo: smbpasswd: command not found
stanley82@Ian-desktop:~$

Comment from Jonathan Moeller
Time June 26, 2008 at 2:02 pm

Ian:

I haven’t used Xubuntu nearly as much as the main Ubuntu versions, so I’m not entirely sure how to advise you. If I’d had to guess, I’d say that you had the GUI package manager open while trying to use apt-get, which doesn’t work, since they both try to lock the same directory at the same time.

Comment from Ian
Time June 28, 2008 at 3:02 pm

On my Ubuntu AMD 64 machine with hardy (not xubuntu) I got this far on this retry. What is this about password length? It looks like my previous try is still there with a short password. Regards Ian.

stanley82@Ian-desktop:~$ sudo apt-get install samba
[sudo] password for stanley82:
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages were automatically installed and are no longer required:
linux-headers-2.6.24-16 linux-headers-2.6.24-16-generic
Use ‘apt-get autoremove’ to remove them.
The following extra packages will be installed:
samba-common
Suggested packages:
openbsd-inetd inet-superserver smbldap-tools
The following NEW packages will be installed:
samba samba-common
0 upgraded, 2 newly installed, 0 to remove and 28 not upgraded.
Need to get 7251kB of archives.
After this operation, 17.4MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://ca.archive.ubuntu.com hardy-updates/main samba-common 3.0.28a-1ubuntu4.3 [3058kB]
Get:2 http://ca.archive.ubuntu.com hardy-updates/main samba 3.0.28a-1ubuntu4.3 [4193kB]
Fetched 7251kB in 1min42s (70.8kB/s)
Preconfiguring packages …
Selecting previously deselected package samba-common.
(Reading database … 148904 files and directories currently installed.)
Unpacking samba-common (from …/samba-common_3.0.28a-1ubuntu4.3_amd64.deb) …
Selecting previously deselected package samba.
Unpacking samba (from …/samba_3.0.28a-1ubuntu4.3_amd64.deb) …
Setting up samba-common (3.0.28a-1ubuntu4.3) …

Creating config file /etc/samba/smb.conf with new version

Setting up samba (3.0.28a-1ubuntu4.3) …
tdbsam_open: Converting version 0 database to version 3.
account_policy_get: tdb_fetch_uint32 failed for field 1 (min password length), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 2 (password history), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 3 (user must logon to change password), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 4 (maximum password age), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 5 (minimum password age), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 6 (lockout duration), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 7 (reset count minutes), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 8 (bad lockout attempt), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 9 (disconnect time), returning 0
account_policy_get: tdb_fetch_uint32 failed for field 10 (refuse machine password change), returning 0
Importing account for nobody…ok
Importing account for stanley82…ok
* Starting Samba daemons [ OK ]

stanley82@Ian-desktop:~$

Comment from Ian
Time June 28, 2008 at 7:19 pm

I’ve made some progress. Using the app-get method I successfully installed samba on the Xubuntu machine. Then on the (gnome) Ubuntu machine after an un-install. On win 98 machine I do not see anything other than itself. On Ubuntu I can access the Xubunu machine but not win98 and on the Xubuntu Places I do not have a Network option so I’m dead using the gui on that system. Any suggestiions? Regards Ian.

Comment from Jonathan Moeller
Time June 28, 2008 at 9:25 pm

Ian:

Good to hear. Apt-get is always better for Samba than the GUI (and, if you’re using the server edition, there’s no GUI anyways).

The TCP/IP stack in Win98 is comparatively primitive; it might not be able to see the Linux shares at all. That said, try accessing the shares via IP address instead of hostname, or FQDN (if applicable). Win98 is not a safe OS to take on the Internet nowadays; you might be better off replacing it with Xubuntu or Damn Small Linux, if the machine is old enough.

Comment from Felipe
Time July 25, 2008 at 9:52 am

Hi there, this is a great tutorial. My Samba it’s working perfectly except for one thing. I have this share that everybody can see, the problem is that when I copy something to the shared folder, the owner and permissions changed completely. This happens both with windows and ubuntu users. For example, somebody puts a document in the folder so that everybody can see it, but since it’s permissions and owner are not the same as the folder where it resides, nobody can open it. How can I make every file copied to the shared folder have the same owner as the folder owner, and the same permission as the rest of the files?

Comment from Jonathan Moeller
Time July 25, 2008 at 1:03 pm

Felipe:

I believe you would have to set the shared folder’s permissions so that everyone can view anything within the folder.

Comment from David Brown
Time August 18, 2008 at 10:11 pm

Hey Jonathon – Great contribution! Thanks alot!

Comment from mark a smith
Time August 19, 2008 at 10:38 am

very helpful.

Comment from Ubuntamus
Time September 12, 2008 at 9:30 am

Felipe:

Using GUI:

Right click on the folder (shared) and check sticky. Any folder created will have de same owner/group/others. On the smb.conf you got to use a property directory mask = 750, and you will have no problems maintaining the folder properties (permissions). Good Luck…

Comment from taels
Time September 21, 2008 at 3:48 am

thanks man. Good guide.

Comment from Dustmite
Time October 6, 2008 at 11:11 pm

I stumbled on your blog post and you seem to be willing to offer some assistance to those having problems so I thought I would take a chance and toss you my mind bender. By the way, I tossed my smb.conf file and built a new one just like you had and no change in my problem. But here is what I set out to do and how I have built my smb.conf file to date – I want a general shared storage location and I want multiple computers to have access with full control. But I did not want guest access. I did all this command line and suspect I am missing something basic but not basic enough for me to grab.

Here is what I did:

1) Built my own smb.conf file which currently reads:

[global]
workgroup = WORKGROUP
map to guest = Bad User
netbios name = Evo

[storage]
comment = Data Storage
path = /data
read only = NO
force user = home
force group = storage
guest ok = No
nt acl support = NO

2) sudo groupadd storage
3) sudo useradd -m home
4) sudo passwd home
5) sudo mkdir /data
6) sudo chmod 770 /data (I wanted user and group to have full but not other)

7)sudo chown -R home:storage /data
sudo chmod -R ug+rwxs /data
9) sudo /etc/init.d/samba restart

My server currently shows up online and so does my shared folder. When I try to connect to the shared folder I am correctly prompted for my user login and password but when I enter it the authentication is rejected. I have redone the “passwd” in case I screwed up the password the first time, but I still have the same problem. If I change the “guest ok = no” to “guest ok = yes” then I can get straight into the shared folder…but that is not what I want.

Personally I am stumped and what I see on the internet either does not seem to apply or confuses the heck out of me.

Comment from Jonathan Moeller
Time October 7, 2008 at 2:33 pm

Dustmite:

It depends on the computer you’re accessing the Samba share from. If it’s a Windows machine, I think you’ll need to enter the username in a format like this:

HOSTNAME\username

(Where HOSTNAME is the name of the server with the Samba share; you might also try its IP address.)

Comment from Suwanto
Time October 15, 2008 at 10:43 am

Important thing I learned how to access samba shares:
Samba and Ubuntu use different userlist and password.
Samba has its own userlist and password.
Ubuntu has its own userlist and password.

To access samba share from another PC, we have to create userlist for samba, via:
sudo smbpasswd
or
sudo pdbedit

Thanks, Suwanto.

Comment from ChrisW
Time November 11, 2008 at 10:24 pm

Hey, thanks for the simple example on configuring this without a GUI. All the other stuff I found made it sound a lot harder!

Pingback from Tech Screeds » Basic Samba Setup In Ubuntu 8.10 Intrepid Ibex
Time December 15, 2008 at 5:03 pm

[...] My most popular post ever is the one I wrote back in May explaining how to do basic Samba filesharing setup in Ubuntu 8.04 Hardy Heron. Now Ubuntu 8.10 Intrepid Ibex has come out, which means it’s time for a post explaining how to do basic Samba setup for 8.10. [...]

Comment from Michael de Silva
Time December 20, 2008 at 11:17 pm

Thanks; this worked like a charm :)

Note to new installs of 8.10 ~ You need to perform an ‘apt-get update’ and ‘apt-get dist-upgrade’. Only once you do this, will ‘apt-get install samba’ work.

Also make sure to enable the third-party repos via the synaptic manager. I had to also edit my sources.list file to choose a better repo.

Anyone looking to setup samba would also probably want it on a static IP. To fix this I install Wicd (apt-get install wicd); it ensures the IP is static at each reboot, and is a far better interface manager.

Cheers
Mike

Comment from Burp Reynolds
Time December 27, 2008 at 12:33 pm

>Try accessing the shared folder from another computer on your LAN (to start, it would >probably be easiest to access it by IP address)

And how do I try accessing the shared…(with or without the) IP address?

Comment from paco
Time January 10, 2009 at 4:18 pm

This works perfect!!! thanks a lot

Comment from chrisc
Time May 27, 2009 at 7:42 pm

i search the net for solution and come across with your blog. i hope that u can give me the solutions which i cannot find at others places.

i successfully setup samba on ubuntu 8.04, user from xp can access the share on ubuntu but the problem is, the connection to the server keep disconnect after a while, user cannot access the share and putty unable to connect. i can ping the server just cannot connect to the server. after a while then it will recover, users able to access share, puty can connect. then after a while the same problem occurs again. this go on and on.

hoping that u can solve this problem that have bug me for months.

thanks

Comment from toby
Time June 19, 2009 at 2:42 am

Dude, solid tutorial. Samba install went smoothly. About to check xp machine to see if this file server is actually going to work. Tutorials like these show linux’s worth! Thanks again

Comment from suingi
Time June 20, 2009 at 4:37 am

Sorry.
I cannot save my password
root@uebserv:~# sudo smbpasswd -a treasurer
New SMB password:
Retype new SMB password:
Failed to modify password entry for user treasurer
root@uebserv:~#

Can somebody tell me what to do
Suingi

Comment from l|zz
Time September 25, 2009 at 7:22 am

@suingi probably a little late but for future reference.
To add a user with smbpasswd there has to be a system user with the same name. So create a system user with adduser and then use smbpasswd

Comment from Lee
Time January 3, 2010 at 8:56 pm

I had the same problem mentioned originally here. Samba users couldn’t get access once I completed the 7.10 to 8.04 (Hardy) upgrade. For me, all I had to do was go in as root and reset each user’s Samba password. The commands looked something like this for user = ‘daniel’:

sudo smbpasswd -a daniel

Then I entered a new password and things started working.

I’m not sure what would happen if you ask the users to reset their own passwords as, according to the docs, it will ask for the old password and, obviously, the old password isn’t working.

I suspect it has something to do with new certificates created for the system itself during the Hardy upgrade. But I’m no expert.

Comment from Gopal Kumar
Time February 27, 2010 at 10:44 pm

Thanks. I just setup the samba share network with my Ubuntu 8.04 laptop and windows home PC. No problem just followed these short instructions. Thanks.

Comment from NimElits
Time May 7, 2010 at 7:44 pm

And there is what some alternative?

Comment from tamer
Time June 20, 2010 at 8:10 am

thank you for the inform.

Comment from Anna
Time June 21, 2010 at 10:37 pm

Thanks for the info. It was very useful – I’ve searched for this for days.

Comment from Dustin
Time June 27, 2010 at 4:08 pm

Hi,
Thanks very good tutorial ;)
Regards,
Dustin

Comment from Chompi
Time November 13, 2010 at 5:35 am

Very well. That works for the TEST and then?
How do you use samba with the Hardy Heron system evry time you want to add, modify, delete sharings with different properties?

Comment from lokir
Time November 27, 2010 at 8:47 am

Easy and fast set-up. Thanks very much. My tomato router is now ready to use samba as a external log storage.

Comment from medfokus
Time February 26, 2011 at 4:07 pm

Thanks for taking the time to share your view with us.

Write a comment

You need to login to post comments!