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: http://au1.samba.org/samba/docs/Samba-HOWTO-Collection.pdf

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:

smb:\>

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 newsletter!

Error: Please check your email address.
Rocket to Success - Your 10 Tips for Smarter ERP System Selection
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 Articles

Resources

PCW Evaluation Team

Ben Ramsden

Sharp PN-40TC1 Huddle Board

Brainstorming, innovation, problem solving, and negotiation have all become much more productive and valuable if people can easily collaborate in real time with minimal friction.

Sarah Ieroianni

Brother QL-820NWB Professional Label Printer

The print quality also does not disappoint, it’s clear, bold, doesn’t smudge and the text is perfectly sized.

Ratchada Dunn

Sharp PN-40TC1 Huddle Board

The Huddle Board’s built in program; Sharp Touch Viewing software allows us to easily manipulate and edit our documents (jpegs and PDFs) all at the same time on the dashboard.

George Khoury

Sharp PN-40TC1 Huddle Board

The biggest perks for me would be that it comes with easy to use and comprehensive programs that make the collaboration process a whole lot more intuitive and organic

David Coyle

Brother PocketJet PJ-773 A4 Portable Thermal Printer

I rate the printer as a 5 out of 5 stars as it has been able to fit seamlessly into my busy and mobile lifestyle.

Kurt Hegetschweiler

Brother PocketJet PJ-773 A4 Portable Thermal Printer

It’s perfect for mobile workers. Just take it out — it’s small enough to sit anywhere — turn it on, load a sheet of paper, and start printing.

Featured Content

Product Launch Showcase

Latest Jobs

Don’t have an account? Sign up here

Don't have an account? Sign up now

Forgot password?