When you come from GUI to text-based terminal, you might miss the cut and past mouse functionality.

You can use your mouse to copy and paste at a terminal. Install gpm which is a cut and paste utility and mouse server for virtual consoles.

What is gpm?

gpm‘ provides mouse support to text-based Linux applications like the Emacs editor and the Midnight Commander file management system. Gpm also provides console cut-and-paste operations using the mouse and includes a program to allow pop-up menus to appear at the click of a mouse button.

From the man page, “This package tries to be a useful mouse server for applications running on the Linux console. It is based on the “selection” package, and some of its code comes from selection itself. This package is intended as a replacement for “selection” as a cut-and-paste mechanism; it also provides additional facilities. The “selection” package offered the first cut-and-paste implementation for Linux using two mouse buttons, and the cut buffer is still called “selection buffer” or just “selection” throughout this document. The information below is extracted from the texinfo file, which is the preferred source of information.”

Install gpm

If you are using Debian Linux, type the command:
# apt-get install gpm

If you are using Ubuntu Linux, type the command:
$ sudo apt-get install gpm

If you are using Red Hat Enterprise Linux, type the command:
# up2date gpm

If you are using Fedora Core Linux, type the command:
# yum install gpm

Task: Select text (copy text)

To select text press the left mouse button and drag the mouse.

Task: Paste text

To paste text in the same or another console, press the middle button. The right button is used to extend the selection, like in ‘xterm’.

Task: Start/stop mouse service

# /etc/init.d/gpm stop | start
$ sudo /etc/init.d/gpm stop | start

Please note that two-button mice use the right button to paste text.

Read man page of gpm for more information. See how to configure mouse under FreeBSD for same purpose.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 6 comments so far... add one
CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
6 comments… add one
  • Me Apr 19, 2010 @ 2:56

    Usually users know how to install software in their environment.

  • Matheus Sep 4, 2012 @ 20:34

    Thanks. I hadn’t got in touch with gpm packet yet!

  • Ale Feb 7, 2014 @ 23:32

    Thanks !

  • Ledidou Nov 20, 2014 @ 10:21

    Don’t delete this page !
    I haven’t started a Linux in text mode since 10 years and completly forget this service
    Thanks !

  • Rinku Aug 13, 2015 @ 6:13

    please provide the step by step to configure the mouse in linux nic

  • karthik Nov 18, 2015 @ 3:39

    Thanks, it works good.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum