installing and configuring a CUPS print server on Ubuntu
1. Install CUPS
Run the following command to install the CUPS server and its dependencies:
sudo apt update sudo apt install cups
Once installed, the CUPS service starts automatically.
2. Add User to the lpadmin Group
This step is optional but recommended. by default cups server can be accessed by the system admin user. For security purpose you would want to share the admin user to the remote manager instead create another user. CUPS uses the lpadmin group to manage printers. Add your user to this group:
sudo usermod -aG lpadmin $USER
Log out and log back in for the changes to take effect.
3. Configure the CUPS Server
The main configuration file for CUPS is located at /etc/cups/cupsd.conf. To edit it, use your preferred text editor, such as nano:
sudo nano /etc/cups/cupsd.conf
Key Configuration Directives:
-
Allow Remote Access: Change the default restrictions to allow remote administration.
Replace the <Location /> and <Location /admin> sections with the following:
<Location /> Order allow,deny Allow all </Location> <Location /admin> Order allow,deny Allow all </Location>
-
Listen on All Interfaces:
Uncomment or add the following line to enable CUPS to listen on all network interfaces:
Listen 0.0.0.0:631
-
Restrict Access (Optional):
For better security, you can replace Allow all with specific IP addresses, e.g., Allow 192.168.1.0/24.
- Update authentication type: For some reason cups redirects to local IP address instead of the public ip address if connected outside the network. to fix this issue replace the following parameters.
# Default authentication type, when authentication is required.
DefaultAuthType Basic
DefaultEncryption IfRequested - Share printers with other users
Browsing On
4. Restart CUPS
After modifying the configuration file, restart the CUPS service to apply changes:
sudo systemctl restart cups
5. Enable Printer Sharing
To share printers connected to your server, enable printer sharing:
sudo cupsctl --share-printers
6. Access the CUPS Web Interface
Open a browser and go to the CUPS administration interface:
http://<server-ip>:631
Log in using your system administrator credentials (username and password).
7. Add and Configure Printers
- Use the CUPS web interface to add printers by navigating to Administration > Add Printer.
- CUPS will auto-detect network printers. You can also add printers manually by specifying their IP addresses or device URIs.
8. (Optional) Install Printer Drivers
For certain printers, you may need additional drivers. Install them using:
sudo apt install printer-driver-<driver-name>
You can find specific drivers for many printers in the Ubuntu repositories.
9. Test Your Configuration
Print a test page from the CUPS web interface or using the command line:
lpstat -p # Check printer status lp -d <printer-name> <file> # Send a print job