Inspect X Colour Names Safely with showrgb
showrgb turns the X colour-name database into plain text so you can read, search or diff it like any other file. The examples use the installed showrgb from x11-xserver-utils version 7.7+10build2; its manual identifies the underlying RGB data format as rgb 1.1.0.
The route
Jump straight to the step you need, or tick off Done means at the end.
Allow about ten minutes. You need a shell and the package installed. This guide only reads files and writes redirected output where you explicitly choose a destination. It does not change X configuration, install a colour database or require elevated privileges.
1. Confirm the command and package
Start by checking the executable and package version. These are ordinary read-only commands:
$ command -v showrgb
/usr/bin/showrgb
$ dpkg-query -W -f='${Package} ${Version}\n' x11-xserver-utils
x11-xserver-utils 7.7+10build2
The exact package version will vary between distributions. Keep the version beside any bug report or repeatable build note: the installed package determines which database layout and command behaviour you are testing.
Checkpoint
If command -v prints nothing, stop here. Install the package through your normal system-management process, then rerun the two checks. Do not work around a missing command by copying an untrusted executable into a system directory.
2. Print the default database
Run showrgb without an argument:
$ showrgb | head -n 5
255 250 250 snow
248 248 255 ghost white
248 248 255 GhostWhite
245 245 245 white smoke
245 245 245 WhiteSmoke
The command converts the database back into source form and writes it to standard output. Each useful row contains red, green and blue values followed by a colour name. The output can contain more than one spelling for the same RGB triplet, as the paired ghost white/GhostWhite and white smoke/WhiteSmoke entries show.
The manual documents /usr/share/X11/rgb as the default database. Check that path directly if you need to establish what is present on this machine:
$ test -r /usr/share/X11/rgb.txt && echo readable
readable
$ showrgb /usr/share/X11/rgb.txt | cmp -s - <(showrgb)
$ printf 'comparison status: %s\n' "$?"
comparison status: 0
The installed database is commonly stored as rgb.txt, while the manual's default name omits the suffix. The command itself accepts the database name without .txt, .pag or .dir. On this host, passing the text file explicitly produces the same 753 rows as the default invocation.
3. Save a copy without losing the terminal output
Pipe the output to tee when you want to inspect it and save it at the same time:
$ showrgb | tee /tmp/x-rgb.txt | head -n 3
255 250 250 snow
248 248 255 ghost white
248 248 255 GhostWhite
Verify the saved copy independently:
$ wc -l /tmp/x-rgb.txt
753 /tmp/x-rgb.txt
$ sed -n '1,3p' /tmp/x-rgb.txt
This example writes only under /tmp. If you choose a project or shared directory instead, check its permissions and available space first. Do not redirect over an existing reference file unless that replacement is deliberate: a plain > truncates its destination before showrgb has finished.
4. Read a custom database
The optional argument selects another database. Use an explicit temporary copy when testing a change so the system database stays untouched:
$ cp /usr/share/X11/rgb.txt /tmp/my-rgb.txt
$ printf ' 1 2 3\tcustom blue\n' >> /tmp/my-rgb.txt
$ showrgb /tmp/my-rgb.txt | tail -n 3
144 238 144 light green
144 238 144 LightGreen
1 2 3 custom blue
showrgb reads the file and emits the entries in source form; it does not install the file or alter the default database. The appended line demonstrates the format this database expects: three numeric colour components, whitespace, then a name. Preserve the source file if another program depends on it, and use a new path for experiments.
There is no persistent change to undo in this example. When you have finished inspecting the temporary file, remove that specific file through your normal cleanup process. Keep the original /usr/share/X11/rgb.txt intact.
5. Diagnose a database that will not open
A missing or unreadable argument produces an error and a non-zero exit status:
$ showrgb /tmp/showrgb-does-not-exist
showrgb: unable to open rgb database "/tmp/showrgb-does-not-exist"
$ printf 'exit status: %s\n' "$?"
exit status: 1
The process ID is not involved in this diagnostic. Check the exact path, existence and read permission instead:
$ ls -l /path/to/rgb.txt
$ test -r /path/to/rgb.txt && echo readable
If the file exists but is not at the path you passed, correct the argument rather than adding sudo. Elevated privileges do not repair a typo. Use sudo only when the file's permissions genuinely require it and your system policy permits that access; reading the standard database normally works as an ordinary user.
Remember that the argument is a database path, not a colour name. showrgb navy asks the program to open a file called navy; it does not look up the name. To search the default output, filter after the command instead:
$ showrgb | grep -i '[[:space:]]navy$'
0 0 128 navy
Done means
- Right binary confirmed.
showrgbis the expected executable from the installed X utilities package. - Default database printed. A no-argument run listed the default X colour database.
- Paths understood. You know the difference between the default database path and an explicit input path.
- Custom database tested. A test copy was checked in
/tmpwithout changing the system copy. - Failures diagnosed properly. Missing input was traced through the path and exit status, without treating
sudoas a fix.