You are on page 1of 15

BSC[CS]TY, LINUX ADMINISTRATION

Unit:VI
Server & Printer Management
6.1 Introduction to APACHE Web Server

 Apache web server is an open source and cross-platform web server. It is mostly
and widely used server in the world.
 It is design and develop by Apache Software Foundation in 1995. It is written in C
& XML and runs widely on Linux distributions.
 In this tutorial, we will install apache web server on ubuntu. this whole process
includes the following steps.
Prerequisites
Following are the prerequisites for this installation process.
 A system running Ubuntu , any linux distribution
 An internet connection
 Access to a user account with sudo privileges

Update Package Index


Update the system package index by using following command.

# apt-get update

Installing Apache Server:


This installation process includes the following steps.
To install apache use the following command.
$ apt-get install apache2
BSC[CS]TY, LINUX ADMINISTRATION

type 'y' and press enter, it will start to download and install apache server to the
system. After this process, We can check that server has installed properly by calling
localhost from the browser. As we did in the following screen-shot.

It shows that apache has installed properly and can be accessed from the browser.

All the configuration files for Apache are located in /etc/httpd/conf and
/etc/httpd/conf.d.
The data for websites you'll run with Apache is located in /var/www by default, but
you can change that if you want.
 /etc/httpd/conf : this directory contains the Apache configuration file, httpd.conf.
 /etc/rc.d/ : The tree under this directory contains the system startup scripts. The
Apache installs a startup script named httpd for the Web server under the
/etc/rc.d/init.d directory. This script , which we can use to start and stop the server
from the command line, also automatically starts and stops the server when the
computer is halted, started , or rebooted.
 /var/www : under this directory installs the default server icons, Common
Gateway Interface(CGI) programs, and HTML file in this location.
 /usr/sbin : The executable programs are placed in this directory. This includes
the server executable itself, as well a various utilities.
 /usr/bin : some of the utilities from the Apache package are placed here. For
example, the htpasswd program, which is used for generating authentication
Password files.
BSC[CS]TY, LINUX ADMINISTRATION

Starting and stopping Apache


At this point , you’ve installed your apache server with its default configuration.
Fedora provides a default home page named index.html as a test under the
/var/www/html/ usages directory. The proper way to run Apache is to set system
initialization to have server run after booting, network configuration, and firewall
configuration.
Starting the Apache server manually:
 You can start Apache from the command line of a text-based console, and you
must have root permission to do so.
 The sever daemon, httpd, recognizes several command-line options you can use
to set some defaults, such as specifying where httpd reads its configuration
directives.
 The Apache httpd executable also understands other options that enable you to
selectively use parts of its configuration file.
 Use following command to start Apache:
# systemctl start apache2

 Use this command to stop server:


# systemctl start apache2
Using this command user stops the Apache server.

Restart Apache Web Server:


# systemctl restart apache2

Apache Web Server Status:


# systemctl status apache2

It will produce the following output.

We can see that apache is not installed and status is inactive.


BSC[CS]TY, LINUX ADMINISTRATION

6.2 Using the network file system:


NFS is an abbreviation of the Network File System. It is a protocol of a distributed
file system. This protocol was developed by the Sun Microsystems in the year of
1984.
Network File Sharing (NFS) is a protocol that allows you to share directories and
files with other Linux clients over a network. Shared directories are typically
created on a file server, running the NFS server component. Users add files to them,
which are then shared with other users who have access to the folder

It is an architecture of the client/server, which contains a client program, server


program, and a protocol that helps for communication between the client and server.
It is that protocol which allows the users to access the data and files remotely over
the network. Any user can easily implement the NFS protocol because it is an open
standard.
Any user can manipulate files as same as if they were on like other protocols. This
protocol is also built on the ONC RPC system.

This protocol is mainly implemented on those computing environments where the


centralized management of resources and data is critical. It uses the Transmission
Control Protocol (TCP) and User Datagram Protocol (UDP) for accessing and
delivering the data and files

Following figure illustrates this example.


BSC[CS]TY, LINUX ADMINISTRATION

The Network File System (NFS) is a mechanism for storing files on a network. It
is a distributed file system that allows users to access files and directories located
on remote computers and treat those files and directories as if they were local.

For example, users can use operating system commands to create, remove, read,
write, and set file attributes for remote files and directories.

The NFS software package includes commands and daemons for NFS, Network
Information Service (NIS), and other services. Although NFS and NIS are installed
together as one package, each is independent and each is configured and
administered individually. See Network Information Services (NIS and NIS+) Guide
for details on NIS and NIS+.

6.3 Putting Samba to work:


Configuring Samba withSystem-config-samba
Introduction to SAMBA Server:
Samba uses the Session Message Block (SMB) protocol to enable the windows
operating system (or any operating system) to access Linux files. Using samba, you
can make your Fedora machine look just like a windows computer to other windows
computers on your network.
Windows users can happily access file and print services without knowing or caring
that those services are being offered by a UNIX host.
• All of this is managed through a protocol suite which is currently known as the
"Common Internet File System", or CIFS.
• At the heart of CIFS is the latest incarnation of the Server Message Block (SMB)
protocol, which has a long and tedious history. SAMBA is an open source CIFS
implementation, and is available for free from the http://samba.org/ mirror sites.

• SAMBA is a free implementation of Microsoft’s SMB (Server Message Block)


Protocol originally developed by Andrew Tridgell. SAMBA provides file and print
services for various Microsoft Windows clients and can integrate with a Windows
Server domain, either as a Primary Domain Controller (PDC) or as a domain
member. It can also be part of an Active Directory domain.

• SAMBA runs on most UNIX and UNIX-like systems, such as LINUX, Solaris, AIX
and the BSD variants, including Apple's Mac OS X Server and Mac OS X client.
Samba enables UNIX/LINUX systems to participate in Windows networks as a File
andPrint Server or Client.
BSC[CS]TY, LINUX ADMINISTRATION

• Fortunately, FEDORA includes the SAMBA Web Administration Tool orSWAT,


which can be used to configure SAMBA by using Mozilla Web browser. SWAT
provides an easy way to start & stop SAMBA Server, set up printing services,
defines remote access permissions, & creates SAMBA username & passwords &
shared directories.
• Like most of the software that comes with FEDORA, SAMBA is licensed under
the GPL & is free. It comes as both an RPM & as source code. In both cases
installation is very straightforward, and the software can be installed when we
installed FEDORA.

• Once SAMBA is installed, we can either create the file /etc/smb.conf or use the
smb.conf file supplied with Samba, which is located by default under the
/etc/samba directory with FEDORA.

Configuring Samba with System-config-samba:


1. Open the terminal
2. Install samba with the following command:
sudo apt-get install samba smbfs
3. Configure samba typing:
vi /etc/samba/smb.conf
4. Set your workgroup (if necesary). Go down in the file, until you see :

# Change this to the workgroup/NT-domain name your


Samba server will part of workgroup = WORKGROUP
5. Set your share folders. Do something like this (change your path and
comments)

# Adrian's
share
[MyShare]
comment = YOUR
COMMENTS path =
/your-share-folder
BSC[CS]TY, LINUX ADMINISTRATION

6. Restart samba.
type: /etc/init.d/smbd restart
7. Create the share folder:
sudo mkdir /your-share-folder
8. Set the permissions:
sudo chmod 0777 /your-share-folder
9. you are all set in Linux

Configuring Samba with SWAT:


SWAT is a tool that allows Web-based configuration of Samba. It has a wizard
that may help to get Samba configured quickly, it has context-sensitive help on each
smb.conf parameter, it provides for monitoring of current state of connection
information, and it allows network wide MS Windows network password
management SWAT - the Samba Web Administration Tool provides a really quick
and easy way to set up a Samba server, with more powerful configuration options
available to those who need them. It's already part of the Samba package that is
available from pkgsrc, and you don't even need to install and configure an HTTP
server like Apache to use it.
Instead of running SWAT from your local browser, you can also run the SWAT
program from another computer on the network, by substituting the server
computer's name for localhost. (To allow computers besides localhost to access the
swat service, you must change or remove the only_from = 127.0.0.1 line from the
/etc/xinetd.d/swat file and restart the xinetd service.) At this point, the browser will
prompt you for a user name and password. Enter the root user name and password.
The SWAT window should appear, as shown in Figure :
BSC[CS]TY, LINUX ADMINISTRATION

Figure: Use SWAT from your browser to manage your Samba configuration.
The rest of this section describes how to use SWAT to create your configuration
entries (in /etc/samba/smb.conf) and to work with that configuration.

6.4 Configuring And Managing Print Services:

1. In a graphical desktop environment, click Main Menu => System Settings =>
Printing.
2. Type the command redhat-config-printer at a shell prompt (for example, in a
command-line terminal window) to start the graphical version.

Managing Print Services:


In Linux, different commands are used to print a file or output. Printing from a
Linux terminal is a straightforward process. The lp and lpr commands are used to
print from the terminal. And, the lpg command is used to display queued print
jobs.
Printing the double-sided document or in portrait mode is a bit complicated process.
And there may be many other operations that we want to perform, such as printing
multiple copies or canceling a print job, which can be difficult to perform.
BSC[CS]TY, LINUX ADMINISTRATION

Linux lp and lpr command


CUPS (Common Unix Printing System) provides the system commands for printing
files. Additionally, it supports several standard options to control the print operation.
Let's see how to print files.

How to print files in Linux


To print files from Linux terminal, execute the lp and lpr command. It will print the
file from the default printer. Execute it as follows:

1. lp < file name>


2. lpr <file name>

The above commands will print the specified file.

Choosing a Printer

If our system has connected with more than one printer, you can choose one of
them to print the particular file. These printers can be connected with different
methods such as parallel, serial, USB port, networking.

To display a list of the connected printers, execute the command as follows:


1. lpstat -p -d

The above command will display a list of available printers. The '-p' option is used to
display a list of the printers, and the '=d' option specifies the default printer.

To print a file with a specific printer, execute the lp command with the '-d' option or
lpr command with the '-P' option. Consider the following commands:

1. lp -d <printer name> <file name>

Setting the Default Printer


We can set a particular printer as a default printer from the connected printers. To
set a printer as the default printer, execute the lpoptions command with the '-d' option
as follows:

1. lpoptions -d < printer name>


BSC[CS]TY, LINUX ADMINISTRATION

Printing Multiple Copies


The lp and lpr both commands support to print multiple copies of a file. To specify the
number ofcopies, use the '-n' option with lp command as follows:

lp -n number <file name>

Creating Network Printer:


Share the printer on the primary PC
1. Select the Start button, then select Settings > Devices > Printers & scanners.
2. Choose the printer you want to share, then select Manage.
3. Select Printer Properties, then choose the Sharing tab.
4. On the Sharing tab, select Share this printer.

Creating and Configuring Local Printers:


Creating a local printer for your Fedora system can be accomplished in six easy
steps. You must have root permission to use the system-config-printer client. The
cupsd daemon should also be running before you begin (start the daemon manually
as shown earlier in this chapter, or use the ntsysv, chkconfig, or system-config-
services commands to ensure that lpd is started at boot time).

To launch system-config-printer, select the Printing menu item from the GNOME
or KDE desktop panel's System Settings menu or use the command line of an X
terminal window like this:
# system-config-printer &

Creating the Print Queue


The Fedora system-config-printer tool walks you through a process to create a new
print queue, which effectively defines a new printer on your system. To begin
configuration of a local (attached) printer, click the New toolbar button in system-
config-printer's main window. An Add a New Print Queue configuration dialog
appears, as shown in Figure :

Figure : Click the New toolbar button to start the configuration of a new
printer for your system; when the wizard's dialog appears, click the Forward
button to begin.
BSC[CS]TY, LINUX ADMINISTRATION

Click the Forward button; the Queue Name dialog appears. Type a desired name for
the new printer (such as lp), enter a short description, and then click the Forward
button.
The Queue Type dialog appears, You can configure a local or networked printer
supported by the Common UNIX Printing System (CUPS), the lpd daemon on a
remote server, a Session Message Block (SMB) server, NetWare Core Protocol
(Novell), or a JetDirect interface. To configure a printer attached to your computer,
select the locally connected queue type, click to select the printer device (which
might be /dev/lp0 or /dev/usb/lp0), and then click Forward. You can also use the
Custom Device button to enter a different port, such as /dev/ttyS0, for a serial printer.
BSC[CS]TY, LINUX ADMINISTRATION

Figure :. Click the drop-down menu to select a locally connected printer


queue type.

The Printer Model dialog shown in Figure : presents a drop-down menu you can use
to choose the manufacturer of your printer, or you can simply choose a generic type
of connected printer.
Figure : Click the drop-down menu to select your printer's
manufacturer or printer type.
BSC[CS]TY, LINUX ADMINISTRATION

Note that you can configure a printer for Fedora even if it is not attached to your
computer. After you select your printer's manufacturer, a list of printers from that
manufacturer (such as HP, as shown in Figure 12.4) appears. Select your printer
from the list, and then click the Forward button.

Figure : Select your printer from the list and click the Forward button to finish the
configuration of a locally connected printer.

Do not worry if you do not see your printer listed in the selection; it is possible to
select a related, although different, printer model and still be able to print to your
printer. For example, many HP printers can be used by selecting the DeskJet 500
for monochrome or 500C model for color printing.

Note
You can also browse to http://www.linuxprinting.org/ to find out what drivers to
use with your printer or to see a cross-referenced listing of printers supported by
each driver. You might also find new and improved drivers for the latest printers
on the market.

You can experiment to see which printer selection works best for your printer if its
model is not listed. You might not be able to use all the features of your printer, but
you will be able to set up printing service. Click Forward when you have made your
choice.
BSC[CS]TY, LINUX ADMINISTRATION

The Finish and Create New Print Queue dialog shows you the printer type, printer
device, and selected printer so that you can confirm the information is correct (see
Figure 12.5). If you need to change the options, click Back to return to previous
dialogs. To create the new print queue, click Finish.

Figure . Double-check your settings before you commit to creating a new


printer entry in /etc/printcap; when the settings are right, click Finish to create
the new print queue.

When the print queue has been created, you are asked whether you would like to
print a test page. Click Yes to save your new printer setup and to print a test page.
If you click No, a test page is not printed, and you have to delete the new printer
entry or save or cancel your changes before you quit system-config-printer.

You can see the new printer defined in the system-config-printer main window
as shown in following Figure :
BSC[CS]TY, LINUX ADMINISTRATION

Figure 12.6. New printer entries created in /etc/printcap will be displayed in


system-config-printer's main window.

You might also like