Install, Configure & Share Printer in Linux | Set Up CUPS Print Server on CentOS 8 (RHEL 8)
HTML-код
- Опубликовано: 22 авг 2024
- 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.
Thank you so much for a clear explanation of CUPS. This will really help me so much.
Glad it was helpful!
Superb video , we can also take print in Linux machines using cups ...
Yes
Thank you easy step follow, I have usb printer and install CentOS 9 can use same method ?
Yes, absolutely
Thanks for tutorial. I am doing the CUPS server migration and found a user pdfspool who is this user? should i create this and this will come with some kind of package installation?
one of my client environment having out dated windows machines i.e. windows 7... etc. they want to use client machine as windows 7 to give prints without any issues. can you please suggest us which is suitable OS to deploy print management. in environment already they are having windows server 2012, 2012 R2, 2016 but the problem post installing the patches on those servers unable to print from windows 7 or outdated OS.
You can use CentOS 7
@@NehraClasses Thank so much for your help.
Hello, good tutorial.
But i have problem with connect printer from windows. Linux printing correctly . Priter is ok, in samba widows work good, with folders share. Problem is when i try connect to pritner show me error about max connections.
Any tips for that?
thanks, please provide us error details in our telegram channel.
How to access WAN sheared printer?? CUPS have only LAN access...
is there anyway to access printer connected to linux in android?
Yes, you can use any terminal software
Hi, I installed Avahi to use the print in my cellphone. Cellphone not need any confirmation. Also Works on airplay.
Hi, I installed Avahi to use the print in my cellphone. Cellphone not need any confirmation. Also Works on airplay.