Install, Configure & Share Printer in Linux | Set Up CUPS Print Server on CentOS 8 (RHEL 8)

Published: 07 September 2020
on channel: Nehra Classes
10,168
103

Set Up CUPS Print Server on CentOS 8/RHEL 8:
=====================================

Step 1: Install and Configure CUPS on CentOS 8/RHEL 8
CentOS 8/RHEL 8 desktop edition has CUPS pre-installed. If you use CentOS 8/RHEL 8 server edition, you need to run the following command to install CUPS from the default CentOS 8/RHEL 8 repository.
dnf install cups

Then start CUPS.
systemctl start cups

Enable auto-start at boot time.
systemctl enable cups

Check its status:
systemctl status cups

Next, edit the CUPS main configuration file with a command-line text editor like Nano.
vim /etc/cups/cupsd.conf

Find the following line.
Listen localhost:631

Change it to the following, So CUPS will listen on all network interfaces.
Port 631

Browsing On

The above configuration only allows access to the CUPS web interface from localhost. To allow access from other computers in the same network, add Allow @LOCAL to the configuration like below.

Allow @LOCAL

If you want to allow remote administration from local network, also add it for the /admin directory.

Allow @LOCAL

Save and close the file. Then restart CUPS for the changes to take effect.
systemctl restart cups

We need to allow clients in the same network to access port 631 on your CentOS 8/RHEL 8 computer.
firewall-cmd --permanent --add-port=631/tcp

Reload firewall for the change to take effect.
systemctl reload firewalld

In addition to the main cups.service, there’s also cups-browsed.service, which is used to scan and add printer from the local network.
systemctl start cups-browsed

And enable auto-start at boot time.
systemctl enable cups-browsed

Step 2: Install Driver for Your Printer on CentOS 8/RHEL 8
You need to install driver on CentOS 8/RHEL 8, so it can recognize and use the printer. If you have an HP printer, you can easily install the driver with the following command.
dnf install hplip

I also recommend installing the gutenprint-cups package, which provides CUPS drivers for Canon, Epson, HP and compatible printers.
dnf install gutenprint-cups

vim file.txt
Nehra Classes Are Awesome!!!

Set Default printer & check the status.
lpoptions -d HP-Deskjet-3540
lpstat -t

Then run the following command to print this text file from the command line.
lp file.txt

This is a very rudimentary method, so don’t worry about printing quality now.

Step 3: Share CUPS Printer via Bonjour/IPP Protocol
Installing Avahi-daemon
dnf install avahi

We also need to install the nss-mdns package from EPEL repository, which is needed for clients to resolve .local domain on the network.
dnf install epel-release
dnf install nss-mdns

Start avahi-daemon.
systemctl start avahi-daemon

Enable auto-start at boot time.
systemctl enable avahi-daemon

Avahi-daemon listens on UDP port 5353. Open it in the firewall.
firewall-cmd --permanent --add-port=5353/udp

Reload firewall for the change to take effect.
systemctl reload firewalld

add bonjour printer on windows

To install Samba on CentOS 8/RHEL 8, run the following command.
dnf install samba

Then issue the following command to start the smbd and nmbd service.
systemctl start smb nmb

Enable auto-start at boot time.
systemctl enable smb nmb

To check if Samba service is running, issue the following commands.
systemctl status smb nmb

Once started, the smb daemon will be listening on TCP port 139 and 445. The nmbd will be listening on UDP port 137 and 138. Run the following command to open these ports in the firewall.
firewall-cmd --permanent --add-service=samba

Reload firwall daemon for the change the take effect.
systemctl reload firewalld

Then edit the main configuration file.
vim /etc/samba/smb.conf
We need to change the value of browseable to yes, so clients in the same network can find the printer and add guest ok = yes to allow anyone in the network to use the printer.

[printers]
comment = All Printers
path = /var/tmp
printable = Yes
create mask = 0600
browseable = yes
guest ok = yes

It’s recommended to enable the spoolssd service when sharing printer. This will make Samba more efficient when there’s lots of printing jobs. Simply add the following two lines in the [global] section to enable the spoolssd service.

rpc_server:spoolss = external
rpc_daemon:spoolssd = fork

Save and close the file.

Create & add samba user and then restart Samba.
useradd samba
passwd samba
smbpasswd -a samba
systemctl restart smb nmb

Adding a Samba-shared Printer in Windows.
Open file explorer, enter the IP address of the CentOS 8/RHEL 8 computer in the address bar like \\192.168.0.110. The printer should now be listed.

===
Thanks for watching the video. If it helped you then, please do like & share it with others as well. Feel free to post your queries & suggestions, we will be glad to answer your queries.
===
©COPYRIGHT. ALL RIGHTS RESERVED.


Watch video Install, Configure & Share Printer in Linux | Set Up CUPS Print Server on CentOS 8 (RHEL 8) online, duration hours minute second in high quality that is uploaded to the channel Nehra Classes 07 September 2020. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 10,168 times and liked it 103 visitors.