Yandex Cloud
Search
Contact UsTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2026 Direct Cursus Technology L.L.C.
Tutorials
    • All tutorials
      • Publishing game updates using Cloud CDN
      • Creating an SAP program in Yandex Cloud
      • Deploying a Minecraft server in Yandex Cloud
      • Deploying a multiplayer server for GTA V in Yandex Cloud
      • Converting a video to a GIF in Python
      • Configuring printing from Cloud Desktop to a local printer in Linux

In this article:

  • Getting started
  • Required paid resources
  • Prepare the infrastructure
  • Configure the local machine
  • Configure the desktop
  • Check the result
  • Troubleshooting
  • How to delete the resources you created
  1. Application solutions
  2. Other
  3. Configuring printing from Cloud Desktop to a local printer in Linux

Configuring printing from Yandex Cloud Desktop to a local printer in Linux

Written by
Yandex Cloud
Updated at January 20, 2026
  • Getting started
    • Required paid resources
  • Prepare the infrastructure
  • Configure the local machine
  • Configure the desktop
  • Check the result
    • Troubleshooting
  • How to delete the resources you created

This guide will help you configure file printing from Yandex Cloud Desktop to a printer connected to a local Linux machine. The solution is built around a shared folder: print jobs from the cloud environment are saved to a shared folder, the local system intercepting and sending them to a physical printer.

Note

This guide gives an example of connecting a virtual printer for printing into a PDF file. To use a printer connected to your local machine (server), add that printer on the CUPS print server. In which case you will not have to install the printer-driver-cups-pdf PDF printing driver, set up /etc/cups/cups-pdf.conf, create the /tmp/cups-pdf-output folder, or use the PDF verification section.

To configure printing from a Cloud Desktop desktop on a local printer in Linux:

  1. Get your cloud ready.
  2. Prepare the infrastructure.
  3. Configure the local machine.
  4. Configure the desktop.
  5. Check the result.

If you no longer need the resources you created, delete them.

Getting startedGetting started

Sign up for Yandex Cloud and create a billing account:

  1. Navigate to the management console and log in to Yandex Cloud or create a new account.
  2. On the Yandex Cloud Billing page, make sure you have a billing account linked and it has the ACTIVE or TRIAL_ACTIVE status. If you do not have a billing account, create one and link a cloud to it.

If you have an active billing account, you can navigate to the cloud page to create or select a folder for your infrastructure.

Learn more about clouds and folders here.

Required paid resourcesRequired paid resources

The infrastructure support costs include:

  • Fee for using the desktop’s computing resources, disks, and for outbound traffic (see Yandex Cloud Desktop pricing).
  • Fee for NAT gateway usage and outbound traffic (see Yandex Virtual Private Cloud pricing).

Prepare the infrastructurePrepare the infrastructure

If you do not have a desktop yet, create one:

  1. Create a network and subnet for the desktop.
  2. Set up a NAT gateway for the desktop.
  3. Create a desktop group. When creating it, select an image with a Linux-based OS, e.g., Ubuntu 20.04.
  4. Create a desktop.

Configure the local machineConfigure the local machine

Configure your local machine to receive files from the desktop.

Linux
  1. Install the necessary tools:

    • The inotify-tools utility.
    • CUPS print server.
    • The printer-driver-cups-pdf package for virtual PDF print checks. To configure a physical printer, install that printer’s driver.
    • The [Samba]https://en.wikipedia.org/wiki/Samba_(software) package.

    Do it by running these commands:

    sudo apt update
    sudo apt install inotify-tools cups printer-driver-cups-pdf samba
    
  2. Create a shared folder at /srv/printdrop and set up access permissions for it:

    sudo mkdir -p /srv/printdrop
    sudo chown lp:lp /srv/printdrop
    sudo chmod 0770 /srv/printdrop
    

    This folder will be used for file exchange between the desktop and the local machine.

  3. Set up Samba:

    1. Open /etc/samba/smb.conf:

      sudo nano /etc/samba/smb.conf
      
    2. Add this code at the end of the file:

      [printdrop]
        path = /srv/printdrop
        browseable = yes
        writable = yes
        guest ok = yes
        force user = lp
        force group = lp
        create mask = 0660
        directory mask = 0770
      
  4. Configure CUPS:

    1. Open /etc/cups/cups-pdf.conf:

      sudo nano /etc/cups/cups-pdf.conf
      
    2. Find the Out ${HOME}/PDF or #Out ${HOME}/PDF line and replace it with the following:

      Out /tmp/cups-pdf-output
      
  5. Create a folder at /tmp/cups-pdf-output and set up access to it:

    sudo mkdir -p /tmp/cups-pdf-output
    sudo chown lp:lp /tmp/cups-pdf-output
    sudo chmod 755 /tmp/cups-pdf-output
    

    This folder will store files sent for printing.

    Note

    For a physical printer, you do not need to configure /etc/cups/cups-pdf.conf and /tmp/cups-pdf-output. Add a printer to CUPS using the http://localhost:631 admin interface by selecting Administration → Add Printer or using the lpadmin command. Then, use the lpstat -p command to get the queue (physical printer) name.

  6. Configure the service to watch the shared folder:

    1. Create a file named print-watcher.sh:

      sudo nano /usr/local/bin/print-watcher.sh
      
    2. Paste this code into the print-watcher.sh file:

      #!/bin/bash
      WATCH_DIR="/srv/printdrop"
        PRINTER="PDF" # locally installed printer
        USER="lp" # user the print is initiated for
        inotifywait -m -e close_write,moved_to --format '%w%f' "$WATCH_DIR" | while read FILE; do
          if [[ "${FILE,,}" == *.pdf ]]; then
            lp -U "$USER" -d "$PRINTER" "$FILE" && rm -f "$FILE"
          fi
        done
      

      Note

      For a physical printer, in the PRINTER="PDF" parameter, replace PDF with the physical printer (queue) name.

    3. Make the file executable:

      sudo chmod +x /usr/local/bin/print-watcher.sh
      
    4. Create a service file named print-watcher.service:

      sudo nano /etc/systemd/system/print-watcher.service
      
    5. Paste this code into the print-watcher.service file:

      [Unit]
        Description=Watch printdrop and print files
        
        [Service]
        ExecStart=/usr/local/bin/print-watcher.sh
        Restart=always
        User=lp
        Group=lp
        
        [Install]
        WantedBy=multi-user.target
      
  7. Activate the service and restart the printing and file exchange services:

    sudo systemctl daemon-reload
    sudo systemctl restart cups
    sudo systemctl restart smbd
    sudo systemctl enable --now print-watcher.service
    

    Result:

    Created symlink /etc/systemd/system/multi-user.target.wants/print-watcher.service → /etc/systemd/system/print-watcher.service.
    
  8. Run this command to test the service:

    systemctl status print-watcher.service
    

    Result:

    ● print-watcher.service - Watch printdrop and print files
        Loaded: loaded (/etc/systemd/system/print-watcher.service; enabled; preset: enabled)
        Active: active (running) since ...
        ...
    
  9. Save the public IPv4 address of your local machine. One way to learn it is by using Yandex Internetometer. You will need this address to mount the shared folder on your desktop.

Configure the desktopConfigure the desktop

Configure the desktop to send files to the local machine.

Linux
  1. Connect to the desktop.

  2. Install the CUPS server and the cifs-utils package:

    sudo apt update
    sudo apt install cups
    sudo apt-get install cifs-utils
    
  3. Configure the backend for the virtual printer:

    1. Create a file named /usr/lib/cups/backend/printdrop:

      sudo nano /usr/lib/cups/backend/printdrop
      
    2. Paste this code into the file:

      #!/bin/bash
      export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
      if test "$#" = "0"; then
        echo 'file printdrop:/printdrop "PrintDrop" "/printdrop"'
        exit 0
      fi
      
      DROP_DIR="/home/<desktop_user_name>/printdrop"
      mkdir -p /tmp/cups-shared
      
      JOBFILE="$6"  # if CUPS provides the file as an argument
      TS=$(date +%s)-$RANDOM
      OUT="$DROP_DIR/job-$TS.pdf"
      SHARED_OUT="/tmp/cups-shared/job-$TS.pdf"
      
      if [ -n "$JOBFILE" ] && [ -f "$JOBFILE" ]; then
        cp "$JOBFILE" "$SHARED_OUT"
        chmod -R 777 /tmp/cups-shared
        sudo -u <desktop_user_name> /usr/local/bin/copy-as-user.sh "$SHARED_OUT" "$OUT"
      else
        cat - > "$SHARED_OUT"
        sudo -u <desktop_user_name> /usr/local/bin/copy-as-user.sh "$SHARED_OUT" "$OUT"
      fi
      

      Specify the name of the desktop user you will use to send files for printing.

    3. Set up access to the file:

      sudo chmod 755 /usr/lib/cups/backend/printdrop
      sudo chown root:root /usr/lib/cups/backend/printdrop
      
  4. Set up access to the shared folder:

    1. Create a file named /usr/local/bin/copy-as-user.sh:

      sudo nano /usr/local/bin/copy-as-user.sh
      
    2. Paste the helper script code:

      #!/bin/bash
      mv "$1" "$2.tmp"
      mv "$2.tmp" "$2"
      
    3. Set up access to the file:

      sudo chmod +x /usr/local/bin/copy-as-user.sh
      sudo chown root:root /usr/local/bin/copy-as-user.sh
      
    4. Set up permissions:

      sudo visudo
      
    5. At the end of the file that opens, paste this line:

      lp ALL=(<desktop_user_name>) NOPASSWD: /usr/local/bin/copy-as-user.sh
      

      Specify the name of the desktop user you will use to send files for printing.

  5. Create a virtual printer and activate it:

    sudo lpadmin -p DropPrinter -E -v printdrop:/printdrop
    sudo cupsenable DropPrinter
    sudo cupsaccept DropPrinter
    

    You will now see a message that a new printer was added.

  6. Create a folder for shared folder mounting:

    sudo mkdir -p ~/printdrop
    
  7. Mount the shared folder:

    sudo mount -t cifs //<local_machine_IP_address>/printdrop ~/printdrop -o guest,uid=$(id -u),gid=$(id -g)
    

    Specify the IPv4 address you saved earlier.

Check the resultCheck the result

To check the result, send a PDF file for printing.

Linux
  1. On your desktop, create or download any PDF file.

  2. On your desktop, send the PDF file for printing by selecting the new virtual printer.

    You will now see a message that the file was added to the printing queue.

  3. On your local machine, check the printing queue of the virtual PDF printer.

TroubleshootingTroubleshooting

For troubleshooting, use the following commands on your local machine:

Linux
  • Viewing CUPS logs related to incoming print jobs:

    sudo tail -n 10 /var/log/cups/access_log
    

    Result:

    ...
    localhost - - [15/Nov/2025:21:55:01 +0000] "POST /printers/PDF HTTP/1.1" 200 394 Create-Job successful-ok
    localhost - - [15/Nov/2025:21:55:01 +0000] "POST /printers/PDF HTTP/1.1" 200 408591 Send-Document successful-ok
    
  • To view CUPS error logs:

    sudo tail -n 10 /var/log/cups/error_log
    

    Detailed entries report errors:

    ...
    W [15/Nov/2025:21:55:01 +0000] [Job 34] Backend cups-pdf returned status 5 (cancel job)
    
  • To view the PDF files created by the virtual printer:

    sudo ls -l /tmp/cups-pdf-output/
    

    Result:

    total 472
    -rw------- 1 lp lp 239840 Nov 17 19:37 job-1763408227-8471-job_2.pdf
    ...
    

How to delete the resources you createdHow to delete the resources you created

To stop paying for the resources you created:

  1. Delete the NAT gateway.
  2. Delete the desktop.

Optionally, delete the subnets, network, and the desktop group.

Was the article helpful?

Previous
Converting a video to a GIF in Python
Next
All tutorials
© 2026 Direct Cursus Technology L.L.C.