The Linux Page

Terminal prints ^C when hitting Ctrl-C on command line or running process

Many old parchements have much of their text hidden or lost...

As anyone else, I use Ctrl-C all the time.

I start writing something in my terminal and it's not what I needed, I hit Ctrl-C to Cancel that line.

This is the same as the Ctrl-C to Cancel a program. In that case it sends a SIGINT to the running process (this assumes that you are running a process that did not detach itself from your console.)

Although on the command line I often do that because I want to keep what I just typed right there on the screen because I will use it, just not right now. And when a ^C is printed in there, that's just really not practical!?

It looks like this started to appear since Ubuntu 9.10 or so. Nothing wrong, it is part of the POSIX specs, but I wanted to hide it... old habits are hard to break! The command to do is as follow:

stty -echoctl

This command tells your TTY to not (-) echo controls (ctl).

Voilà! That's how you remove the ^C when hitting Ctrl-C in your terminal. Easy... right?

Of course, you should include that in your ~/.bashrc file so that way it's always off when you reboot.

To restore the controls, use the same name without the dash:

stty echoctl

Also, you may use ctlecho, which is a synonym of echoctl.