Configuring Samba 3.0 to act as a Windows File Server

One of the most common roles for a Linux server on a predominately Windows network is as a file and printer server. The effectively free price of Linux makes it a very attractive alternative to the Windows server family. To act as a Windows file and printer server, Linux requires the Samba package, which implements the Windows file and printer sharing protocol (known as SMB or CIFS) under Linux/UNIX.

Installing Samba

A copy of Samba 3.0.0 is included on the PC World January 2004 cover CD. Your Linux distribution may include a copy of an earlier version. Unless you want to use the advanced Active Directory features included in Samba 3.0.0, the version included with your distribution is suitable to perform the tasks outlined in this article.

To compile Samba from the cover CD, copy it to your hard drive and type the following in a shell:

$ bunzip2 -c samba-3.0.0.tar.bz2 | tar xv
$ cd samba-3.0.0/source
$ ./configure
$ make

Once Samba has built, you will need to become the super user (if you are not already logged in as root) by typing ‘su’ and entering the root password. To install your freshly compiled copy of Samba, type the following:

$ make install

Configuring Samba

Samba uses plain text configuration files. The default version of each configuration file is loaded with helpful explanations of each setting and is well worth reading before making changes. The Samba configuration files are commonly located in /etc/samba/ or /usr/local/samba/lib/, but your distribution may place them elsewhere. The configuration file you need to edit is named smb.conf. Here is an example of an smb.conf file which will share a single directory on your Windows network. (Line numbers have been added to aid explanation; be sure to remove them if you copy the example into your own configuration file.)

1: [global] 2: workgroup = WORKGROUP 3: server string = Linux computer 4: [share1] 5: comment = Example share 6: path = /usr/local/public 7: public = yes

The first section of the smb.conf is the global configuration, as indicated by the header on line 1. In this section you can define settings, for example, the workgroup to which the server belongs (line 2), and the name attributed to the computer when listed on the network (line 3). Shared drives can be defined after the global section. Each shared drive must be given a name, such as share1 (line 4). Line 5 is a comment describing the purpose of the share. Line 6 specifies the path that will be shared under this share. Line 7 allows the share to be mounted without the need to enter a password.

Once you have tweaked your con­figuration settings in smb.conf, it is important to test them with the testparm program. Type the following in a shell to verify your configuration settings:

$ testparam /etc/samba/smb.conf

To start the Samba server, as root type the following in a shell:

/etc/init.d/samba start

You should now be able to see your Linux computer on your Windows network when exploring the Network Neighbourhood.

If you have trouble connecting to your Samba server because of a bad password, you will need to add a user to your Samba password file. To do this, type:

$ smbpasswd -a

You will be prompted to enter the password for the user twice before the account is created. Creating a Samba user requires a user with the same name that already exists on your Linux computer.

More advanced Samba documentation can be found in the Samba HOWTO located at:

Browsing Windows servers under Linux

Samba also includes a handy client, creatively named smbclient, which can be used to test your Samba server or to browse other Windows servers. To connect to a Windows server using smbclient, type the following:

$ smbclient //servername/sharename -U username

Change username to a working system login for the computer you are connecting to. After connecting you will be greeted with a prompt similar to:


From here you can use many standard FTP commands such as:

cd — change directory
dir — list directory contents
get  — download  to your computer
put  — upload  to the server

A full list of commands is provided in the smbclient man page which can be accessed by typing:

$ man smbclient

Join the PC World newsletter!

Error: Please check your email address.

Our Back to Business guide highlights the best products for you to boost your productivity at home, on the road, at the office, or in the classroom.

Keep up with the latest tech news, reviews and previews by subscribing to the Good Gear Guide newsletter.

Alastair Cousins

PC World
Show Comments

Most Popular Reviews

Latest News Articles


PCW Evaluation Team

Azadeh Williams

HP OfficeJet Pro 8730

A smarter way to print for busy small business owners, combining speedy printing with scanning and copying, making it easier to produce high quality documents and images at a touch of a button.

Andrew Grant

HP OfficeJet Pro 8730

I've had a multifunction printer in the office going on 10 years now. It was a neat bit of kit back in the day -- print, copy, scan, fax -- when printing over WiFi felt a bit like magic. It’s seen better days though and an upgrade’s well overdue. This HP OfficeJet Pro 8730 looks like it ticks all the same boxes: print, copy, scan, and fax. (Really? Does anyone fax anything any more? I guess it's good to know the facility’s there, just in case.) Printing over WiFi is more-or- less standard these days.

Ed Dawson

HP OfficeJet Pro 8730

As a freelance writer who is always on the go, I like my technology to be both efficient and effective so I can do my job well. The HP OfficeJet Pro 8730 Inkjet Printer ticks all the boxes in terms of form factor, performance and user interface.

Michael Hargreaves

Windows 10 for Business / Dell XPS 13

I’d happily recommend this touchscreen laptop and Windows 10 as a great way to get serious work done at a desk or on the road.

Aysha Strobbe

Windows 10 / HP Spectre x360

Ultimately, I think the Windows 10 environment is excellent for me as it caters for so many different uses. The inclusion of the Xbox app is also great for when you need some downtime too!

Mark Escubio

Windows 10 / Lenovo Yoga 910

For me, the Xbox Play Anywhere is a great new feature as it allows you to play your current Xbox games with higher resolutions and better graphics without forking out extra cash for another copy. Although available titles are still scarce, but I’m sure it will grow in time.

Featured Content

Latest Jobs

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?