Software⏱️ 4 min read📅 2026-06-15

How to Fix: Error in the command "cat file | xclip"

Error in command cat file | xclip occurs when running as non-superuser, causing No protocol specified Error: Can't open display. Solution involves setting default display for all users.

Quick Answer: Set the DISPLAY environment variable to :0 or :1 for all users.

The error 'No protocol specified Error: Can't open display: :0.0' occurs when trying to run the command 'cat file | xclip' on a non-interactive X session, which is what happens when using '$ su another_user; cat file | xclip'. This issue affects users who are not logged in as the original user ('heo') and do not have access to an interactive X session. The error can be frustrating for system administrators and users alike, especially when trying to automate tasks or share output between multiple users.

To resolve this issue, we will explore two primary fix methods: setting up a shared display for all users and changing the default display for each user. We will also investigate why the 'xauth-command' appears black for one superuser with no error message or text.

🛑 Root Causes of the Error

  • The root cause of this issue is that the X session is not properly configured to allow sharing of displays between users. When a user logs in, their X session is created on a specific display (usually ':0' by default), which can lead to issues when trying to run commands that require an interactive X session.
  • Another potential cause could be related to the 'xauth-command', but without more information, it's difficult to pinpoint the exact issue. However, we will investigate further to provide a complete solution.

🚀 How to Resolve This Issue

Shared Display Configuration

  1. Step 1: To set up a shared display for all users, you need to configure the X server to allow sharing of displays between users. You can do this by editing the '/etc/X11/xorg.conf' file and adding the following lines: # Shared Display Configuration Section "Display" { Identifier "SharedDisplay" ScreenType "Direct" } # Add the display to the X server configuration xrandr --addmode :0 SharedMode
  2. Step 2: Next, you need to create a new user group and add the users who want to share displays to it. You can do this by running the following command: # Create a new user group groupadd shared-group # Add the desired users to the group usermod -aG shared-group another_user
  3. Step 3: Finally, you need to set the DISPLAY environment variable for each user who wants to share displays. You can do this by running the following command: # Set the DISPLAY environment variable export DISPLAY=:0

Default Display Configuration

  1. Step 1: To change the default display for each user, you need to edit their X server configuration file. You can do this by running the following command: # Edit the X server configuration file sudo nano /etc/X11/xorg.conf.d/99-default-display.conf
  2. Step 2: In the '/etc/X11/xorg.conf.d/99-default-display.conf' file, add the following lines: # Default Display Configuration Section "ScreenSection" { Screen "DefaultScreen" { # Set the default display to :0 Identifier "DefaultScreen" Device "DisplayDevice" Monitor "Monitor" Depth 24 Dpi 96 Sync RefreshRate 60 SubPixel "RGB" ColorDepth 24 BacklightType "full" \ BacklightName "Backlight" VideoMode "1024x768@60Hz" \ VideoMode "1152x864@75Hz" \ VideoMode "1280x800@60Hz" \ VideoMode "1366x768@60Hz" \ VideoMode "1600x1200@60Hz" \ VideoMode "1920x1080@60Hz" \ VideoMode "2048x1152@75Hz" \ VideoMode "2560x1440@60Hz" \ VideoMode "2880x1800@75Hz" \ } }
  3. Step 3: Save and close the file, then restart the X server to apply the changes: # Restart the X server sudo service xorg restart

🎯 Final Words

To summarize, setting up a shared display for all users or changing the default display configuration can resolve the 'No protocol specified Error: Can't open display: :0.0' issue when running commands like 'cat file | xclip'. By following these steps, you should be able to automate tasks and share output between multiple users without any issues.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions