How to Set Up a Linux Home Server for Printing and File Sharing

Hardware

You don't need the latest and greatest hardware for a home server. You should at least have a 600 mHz processor and 512MB of RAM, but since you will not be using the GUI, you don't need much more than that. What you will need is a considerable amount of hard drive space to hold all of your files. Save money by using old hardware, and put that money to good use buying the largest hard drive you can find. One caveat, some old hardware will not recognize extremely large hard drives, so you should do some research before you purchase.

Software

Obviously, you will need a copy of Linux. There are many different Linux Distributions and we have a fantastic guide to choosing the Linux distro, but for the purpose of this article it really doesn't matter which distro you use. If you are a new user, it is a good idea to go with one of the better known distros – Ubuntu (or any 'buntu), OpenSuse, or Fedora – because they have good forums and it's easy to find help. For purposes of this article, I will be using Ubuntu.

After installing the OS, install the following packages:

samba – for the ability to share data with Windows Computers

openssh-server – for accessing your server over the Internet

cups – for creating a print server

clamav – for virus protection

Installing these packages with Ubuntu is easy. You can either download them from the Synaptic Package Manager in the GUI, or simply type:

sudo apt-get install package-name (replacing package-name with the name of the software)

File Server

The first thing we will configure is the file server. Although Linux understands the NTFS file system, it sometimes causes problems with the read/write permissions between the Window and Linux. Therefore, you should install Samba for data sharing.

Once Samba is installed, you will need to make some configuration changes. Using the command line (terminal) type the following commands:

cd /etc/samba

sudo gedit smb.conf

A text editor will display the smb.conf file. Change the following fields to reflect your network:

WORKGROUP = workgroup or domain group name

MACHINE_NAME = browseable machine name

PDC & BDC = primary domain controller and backup domain controller name

any IP number = your IP scheme or related machine's IP

The Samba HowTo is a good place to look for detailed instructions, sample configurations, or if you just want more information.

Once your smb.conf file is edited, restart the samba daemon:

sudo /etc/init.d/samba restart

Print Server

A print server allows everyone to access the printer without the hassle of plugging it into whichever computer needs it at the time. CUPS (Common UNIX Printing System) is the software that Linux uses to access the printer.

There are two ways to configure CUPS. You can always change the configuration files from the command line, or you can access the configuration files from a web browser. Although I normally recommend using a command line, CUPS is the exception to this rule. Open your preferred web browser and type

https://localhost:631

in the address window.

You will be presented with a GUI that allows you to add your printer with help from a wizard. The wizard is pretty self explanatory, but if you would like more information it can be found in the CUPS User Manual.

SSH

Installing and running SSH is pretty straightforward. As soon as you install the openssh-server package SSH will be running on your server. In order to access the server over the Internet, you will have to make sure that port 23 is open on your browser. Once you have the port open, you can access your server from your internal network by using the command:

ssh username@hostname

or from a remote location, with the command

ssh username@ipaddress

Accessing ssh remotely means you will have to know your home IP address. Since most home users do not have a static IP address you can circumvent having to look it up by using a service such as dyn-dns or no-ip. Both of these services are free, and have Linux clients whose sole purpose is to map a dynamic URL to a static IP.

Security

Every server needs security. For the home server, it is a good idea to close down any unused ports, and limit access by minimizing the number of users who have sudo (super user) access. You should also install and run anti virus software such as ClamAV. Read the Tobias Rice article on the subject for detailed instructions on how to install and set it up correctly.

Finally, you should disable the X-server in order to save CPU usage and prevent wandering hands from making changes. In Ubuntu the command is:

/etc/init.d/gdm stop

Read the free book Securing and Optimizing Linux for an indepth discussion on Linux security.

Conclusion

A home server running Linux is fairly inexpensive and easy to set up. Having one creates a centralized location to place the family's photos, music and videos. The added bonus is now you can back up that one server regularly, and everyone's data will be preserved.

If you are interested in setting up a server for your small business, there is much more to be considered. Take a look at Tolga BALCI's series of articles for more information.