What Are CUPS in Linux?

Topics Covered

What Are CUPS in Linux?

CUPS stands for Common Unix Printing System. It is an open-source printing system that provides a framework for managing and controlling printers in a Linux or Unix environment. CUP in linux was developed by Apple Inc. but is widely used on various Linux distributions as the default printing system.

CUPS in linux is composed of several key components that work together to provide a comprehensive printing solution. These components include:

  • CUPS scheduler:
    This is the central component of CUPS that receives print jobs from applications, queues them, and schedules them for printing. It manages multiple printers and handles the processing of print job attributes, such as page orientation, print quality, and number of copies.
  • CUPS filters:
    CUPS filters are responsible for converting print job data from the format used by the application (such as PostScript, PDF, or image files) into a format that the printer can understand. They ensure that print jobs are correctly processed and optimized for printing. Users can customize or extend these filters to support specific file formats or printers.
  • CUPS backends:
    CUPS backends handle the communication between the CUPS scheduler and physical printers. They support various printing protocols and connection types, such as USB, network printers, Bluetooth printers, and more. CUPS provides preconfigured backends for different printer types, and users can add custom backends to support specialized printers or specific printing setups.
  • CUPS web interface:
    The CUPS web interface is a user-friendly administration tool that allows users and administrators to manage printers and print jobs. It provides a web-based interface accessible through a browser for easy configuration and monitoring of printing activities. Users can view print job status, cancel or hold print jobs, configure printer options, set up printer sharing, and perform administrative tasks like adding or removing printers.

CUPS offers several advantages for Linux users and administrators. It provides a consistent and standardized printing interface across different applications, making it easier to configure and use printers. It also supports advanced features such as printer sharing, printer discovery, and printer access control, which are particularly useful in networked environments.

Installation

Installing CUPS (Common Unix Printing System) on a Linux system is a straightforward process. Here are the general steps to install CUPS:

  • Update the System:
    Before installing any software, it is recommended to update the system's package repositories and software packages. This ensures that you have the latest versions and dependencies.
  • Check CUPS Availability:
    Verify if CUPS is already installed on your system. Open a terminal and type the following command:

If CUPS is already installed, the command will display the version information. If not, proceed with the installation.

  • Install CUPS:
    Use the package manager specific to your Linux distribution to install CUPS. Here are the commands for some popular distributions:
    • Ubuntu/Debian:
    • CentOS/RHEL:
    • Fedora:
    The package manager will download and install the necessary CUPS components and dependencies.
  • Start and Enable CUPS Service:
    Once CUPS is installed, start the CUPS service and enable it to start automatically on system boot. Use the following commands:
    • Ubuntu/Debian:
    • CentOS/RHEL:
    • Fedora:
    The CUPS service will be started, and the necessary system configurations will be set up.
  • Access the CUPS Web Interface:
    CUPS provides a web-based administration interface that you can access through a browser. Open your preferred browser and enter the following URL:
    This will open the CUPS web interface, where you can manage printers, configure options, and perform administrative tasks.
  • Configure and Add Printers:
    In the CUPS web interface, you can configure printers by selecting "Administration" and then "Add Printer". Follow the on-screen instructions to add and configure your printers. Make sure the printers are connected and powered on.

Configuration

When configuring CUPS (Common Unix Printing System) on a Linux system, there are several important directives that you may need to adjust in the CUPS configuration file. Here are two commonly used directives for configuration:

ServerAdmin

The ServerAdmin directive specifies the email address of the system administrator responsible for managing the CUPS server. This email address is displayed on the CUPS web interface and can be useful for users who need to contact the administrator for printer-related issues or inquiries.

To set the ServerAdmin directive:

  • Open the CUPS configuration file using a text editor. The file is usually located at /etc/cups/cupsd.conf.
  • Search for the line containing the ServerAdmin directive.
  • Uncomment the line by removing any leading "#" character.
  • Replace the placeholder email address with the desired email address of the system administrator.
  • Save the changes and exit the text editor. Example:

Listen

The Listen directive specifies the network interfaces and ports on which the CUPS server listens for incoming connections. By default, CUPS listens on the loopback interface (localhost) and port 631. However, you may need to adjust this directive if you want CUPS to listen on specific interfaces or ports.

To configure the Listen directive:

  • Open the CUPS configuration file (/etc/cups/cupsd.conf) in a text editor.
  • Locate the line containing the Listen directive.
  • Uncomment the line by removing the leading "#" character.
  • Add the desired network interfaces and ports. Separate multiple entries with spaces. Example:

In this example, CUPS is configured to listen on both the localhost interface and the specific IP address 192.168.0.100, both on port 631.

When modifying the Listen directive, ensure that the interfaces and ports you specify are appropriate for your network setup and security requirements.

After making changes to the CUPS configuration file, save the modifications and restart the CUPS service for the changes to take effect. Use the appropriate command for your Linux distribution:

  • CentOS/RHEL:

  • Fedora:

With the ServerAdmin and Listen directives properly configured, you can now manage and control your CUPS server, printers, and print jobs according to your specific requirements.

Web Interface

cups web interface

The CUPS (Common Unix Printing System) web interface is a user-friendly tool that allows users and administrators to manage printers, configure settings, and monitor print jobs through a web browser.

How to Use the CUPS Web Interface

Using the CUPS (Common Unix Printing System) web interface is a convenient way to manage printers, configure settings, and monitor print jobs. Here's a step-by-step guide on how to use the CUPS web interface:

  • Access the Web Interface:
    Open a web browser and enter the following URL: http://localhost:631. If you are accessing it from a remote machine, replace "localhost" with the IP address or hostname of the machine running the CUPS server.
  • Home Page:
    The CUPS web interface home page provides an overview of the server status and information, including the version and available printers.
  • Printer Management:
    1. To add a new printer, click on the "Administration" tab and select "Add Printer". Follow the on-screen instructions to add the printer, providing details such as the printer's name, description, and connection type.
    2. To modify printer settings, click on the printer's name under the "Printers" section. This will open the printer's configuration page, where you can adjust settings such as print quality, paper size, and available print modes.
    3. To delete a printer, select the printer from the "Printers" section and click on the "Delete Printer" button. Confirm the deletion when prompted.
  • Print Job Monitoring:
    1. To view active print jobs, click on the "Jobs" tab. This will display a list of active print jobs with details such as job ID, document name, user, and status.
    2. To manage print jobs, you can pause, resume, restart, or cancel individual print jobs using the corresponding buttons next to each job.
  • Printer Sharing:
    1. To share a printer, select the printer from the "Printers" section and click on the "Administration" dropdown menu. Choose "Modify Printer" and enable the sharing options.
    2. You can configure access permissions by selecting the "Administration" dropdown menu and choosing "Set Allowed Users".
  • Administration Tasks:
    To access system-level settings, click on the "Administration" tab. Here you can configure server settings, manage classes (groups of printers), set up printer access controls, manage user accounts, and configure security options.
  • Printer Discovery:
    To automatically detect and add network printers, click on the "Administration" tab and choose "Find New Printers". CUPS will scan the network for available printers and display the detected devices.
  • System Configuration:
    The CUPS web interface allows you to configure system-level settings. Click on the "Administration" tab, then choose options such as server settings, network interfaces, logging options, and the CUPS scheduler.
  • Help and Documentation:
    The web interface provides access to CUPS documentation and help resources. Look for links or icons that lead to additional information, user manuals, troubleshooting guides, and other helpful resources.

Remember that some administrative tasks may require elevated privileges. Depending on your user role, you may have limited permissions when accessing the web interface as a regular user.

How to Add a Printer in CUPS

add printer in cups

Adding a printer in CUPS (Common Unix Printing System) involves a few steps to configure the printer settings and make it accessible for printing. Here's a step-by-step guide on how to add a printer in CUPS:

  • Access the CUPS Web Interface:
    Open a web browser and enter the following URL: http://localhost:631. If you are accessing it from a remote machine, replace "localhost" with the IP address or hostname of the machine running the CUPS server.
  • Navigate to the Add Printer Page:
    Click on the "Administration" tab in the CUPS web interface. Under the "Printers" section, select the "Add Printer" option.
  • Provide Printer Information:
    On the Add Printer page, you will be prompted to provide information about the printer. Follow these steps:
    1. Choose the Connection Type:
      Select the appropriate connection type for your printer. CUPS supports various connection types such as USB, network (IPP, LPD), Bluetooth, and more. Choose the option that matches your printer's connection method.
    2. Specify Printer Details:
      • Enter a name for the printer:
        Provide a descriptive name for the printer that will be displayed in the CUPS web interface.
      • Enter a location:
        Optionally, specify the physical location of the printer (e.g., "Office Room 202").
      • Enter a description:
        Provide additional details or notes about the printer (e.g., "Color Laser Printer").
  • Select Printer Make and Model:
    CUPS provides a list of printer makes and models for automatic driver detection. Choose the manufacturer (make) of your printer from the list. If available, select the specific model. If your printer make and model are not listed, you may need to manually install the printer driver or use a generic driver.
  • Configure Printer Options:
    Depending on your printer model and driver, you may have additional configuration options available. This can include setting the default paper size, print quality, double-sided printing, and other specific printer settings. Adjust these options as needed.
  • Set Printer Sharing:
    If you want to share the printer on the network, select the "Share This Printer" option. You can also configure access permissions for different users or groups.
  • Confirm and Add the Printer:
    Review the printer settings on the confirmation page to ensure they are correct. Click on the "Add Printer" button to add the printer to the CUPS system.
  • Test the Printer:
    After adding the printer, you can choose to print a test page to verify that the printer is working correctly. This option is available on the printer's configuration page.

Once the printer is added, it will be available for printing from any applications or devices connected to the CUPS server. You can manage and configure the printer further through the CUPS web interface, such as adjusting settings or monitoring print jobs.

Ensure that the printer is properly connected, powered on, and accessible by the CUPS server before attempting to add it to CUPS.

Various CUPS commands

cups commands

CUPS (Common Unix Printing System) provides a command-line interface that allows users to perform various administrative and management tasks. Here are some commonly used CUPS commands:

  • lp - Send print jobs to printers:
    The lp command is used to send print jobs to printers. It supports various options to specify printer settings, number of copies, print quality, and other parameters. For example:
  • lpstat - Check print job status:
    The lpstat command displays information about print queues and print jobs. It can be used to check the status of print jobs, printer availability, and other details. For example:
  • cancel - Cancel print jobs:
    The cancel command is used to cancel print jobs that are in the queue. It requires the job ID or the printer name and job ID as arguments. For example:
  • cupsenable and cupsdisable - Enable/disable printers:
    The cupsenable command is used to enable printers that have been disabled, allowing them to accept print jobs. Conversely, the cupsdisable command disables printers, preventing them from accepting new print jobs. For example:
  • lpadmin - Configure printers and classes:
    The lpadmin command is a versatile tool for configuring printers and printer classes. It can be used to add printers, modify printer settings, set access controls, manage classes, and more. For example:
  • lpoptions - Set default printer options:
    The lpoptions command allows users to view and set default options for printers. It provides a way to customize printer settings such as default paper size, print quality, and double-sided printing. For example:
  • system-config-printer - GUI printer configuration tool:
    The system-config-printer command launches a graphical user interface (GUI) tool for configuring printers. It provides a user-friendly interface to add, configure, and manage printers on the system. For example:

These are just a few examples of the many commands available in CUPS. Each command has additional options and functionalities that can be explored by referring to the respective command's manual page (man command) for more detailed information.

How to control the CUPS service

To control the CUPS (Common Unix Printing System) service, you can use the following methods:

  • Start the CUPS service:
    1. Use the command systemctl start cups to start the service.
    2. Alternatively, you can use the command service cups start if you are using an older Linux distribution.
  • Stop the CUPS service:
    1. Use the command systemctl stop cups to stop the service.
    2. Alternatively, you can use the command service cups stop if you are using an older Linux distribution.
  • Restart the CUPS service:
    1. Use the command systemctl restart cups to restart the service.
    2. Alternatively, you can use the command service cups restart if you are using an older Linux distribution.
  • Check the status of the CUPS service:
    1. Use the command systemctl status cups to check the current status of the service.
    2. Alternatively, you can use the command service cups status if you are using an older Linux distribution.
  • Enable the CUPS service to start on boot:
    1. Use the command systemctl to enable cups to enable the service to start automatically when the system boots up.
    2. Alternatively, you can use the command chkconfig cups if you are using an older Linux distribution.
  • Disable the CUPS service from starting on boot:
    1. Use the command systemctl disable cups to disable the service from starting automatically on boot.
    2. Alternatively, you can use the command chkconfig cups off if you are using an older Linux distribution.

These commands assume you have the necessary privileges to control services on your system. If you encounter any permission issues, you may need to run the commands with administrative rights using the sudo command.

Conclusion

  • CUPS in linux is a printing system used in Unix-like operating systems to manage print queues, handle print jobs, and provide printing services.
  • It offers a standardized printing interface and supports various printing protocols and drivers.
  • CUPS in linux provides a web interface that allows users and administrators to manage printers, configure settings, and monitor print jobs.
  • The web interface can be accessed through a web browser using the URL http://localhost:631
  • CUPS in linux enables adding, modifying, and deleting printers through the web interface.
  • Print jobs can be monitored in real-time, allowing users to view job status, pause, resume, restart, or cancel print jobs.
  • Printer sharing is supported, allowing multiple users to access shared printers over the network.
  • CUPS in linux offers administration tools for managing system-wide settings, printer access controls, user accounts, and security options.
  • Printer discovery simplifies the process of adding network printers by automatically detecting and adding available devices.
  • System-level configuration options are available through the web interface, including server settings, network interfaces, logging, and the CUPS scheduler.
  • The CUPS web interface provides access to documentation and helps resources for troubleshooting and additional guidance.
  • Administrative tasks may require elevated privileges to perform certain operations.
  • CUPS in linux supports command-line tools such as lp, lpstat, cancel, and lpadmin for managing printers and print jobs.
  • Controlling the CUPS service is possible using commands like systemctl start/stop/restart/enable/disable/status cups on Linux distributions.