Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been working with copy paste functionality on a Linux system. I downloaded the kernel source for the first time. Where can I find the code related to copy paste functionality?

My guess is that it does not belongs to Kernel part of Linux. If I'm right, Where can I find it?

share|improve this question

You are right, it is not part of the Linux kernel. The kernel is simply not responsible for jobs like that. What is depends on your system. On the console it could be your tty driver, in most graphical environments you are thinking of are probably based on Xorg and use the Xorg selection buffer and clipboard; but you may also be using Wayland; a direct frame buffer driver or another graphical engine and the code may be elsewhere. Even in the case of Xorg, Xorg is not responsible for binding keystrokes and other events to actions. That will come dow to your Desktop Environment or Window Manager which could be a lot of things.

There is no single place to point you to without a LOT more detail about your environment. In the mean time it sounds like you need to read up more on the overall architecture of a Linux system and what systems are in charge of what sort of operations. The eventual answer to your question will almost certainly be found spread across more that one layer and you need to know how they go together to make sense of it.

share|improve this answer
-1: "On the console it could be your tty driver" ... you are guessing instead of knowing. – yeti Jun 14 '14 at 11:26
@yeti The only thing I was guessing at was how to phrase that in a way that the OP would understand without mutilating the details too badly. It's actually more like "on a tty it would be the console driver" but who knows what a TTY is these days? And even that is a horrible oversimplification and not really that accurate. If you think throwing more accurate technical details at this question would be helpful, feel free to post an answer yourself. – Caleb Jun 14 '14 at 11:30
@yeti I used the word "could" because there are other possibilities. Many console apps manage their own copy/paste buffers: see tmux or screen multiplexers that have their own functions for this. Depending on what he's talking about it could be one of several things. – Caleb Jun 14 '14 at 11:32

Copy paste is part of the desktop environment (X11, GNOME, etc). On the console the copy paste would/could be done by the service gpm which provides mouse capabilities when in console mode.

share|improve this answer

For copy-paste on a text mode console, look for a file drivers/tty/vt/selection.c in your kernel sources tree (drivers/char/selection.c in older kernels). The userland part of cut&paste on the virtual terminals is gpm, the "General Purpose Mouse interface".

Copy-paste in the GUI is not handled by the kernel but by X.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.