You can't 'securely' clear these (by writing something else into the memory they occupy), since they aren't stored in your process.There are more than 2 of them, but mostly we worry about the selections PRIMARY and CLIPBOARD.
However this one leaves a \n newline character in the clipboard, so I would not call this method effective either. I also know about this method: os.system('echo '' | xclip -selection clipboard') # empty clipboard So we have 2 problems with this option: 1) It creates a blank file, which seems like a flawed method to me 2) It leaves a process open, which could be a security hole. However the main problem is that by calling both of these scripts, it leaves the xclip process open, even after I close the terminal. Unfortunately this code creates a file named blank for some reason, so we have to remove it: os.remove('blank') Os.system('xclip -selection clipboard blank') The code that I have seen over here is this: # empty X.org clipboard I am writing a simple python script to clear both clipboards, securely preferably, since it may be done after copy-pasting a password. Gnome desktop has 2 clipboards, the X.org (saves every selection) and the legacy one (CTRL+C).