大网数据广告活动
服务器运维问答

Ctrl+C no longer working to get a new blank line in bash

· 52CE 我爱测

I have been using Ctrl+C on most terminals to easily cancel the line I was writing and open the way for a new line. (I'm not talking about killing a running bash script, but just opening a new blank line) For no reason I can thin…

问题原文

原帖链接 · Cyril Duchon-Doris · CC BY-SA 4.0

I have been using Ctrl+C on most terminals to easily cancel the line I was writing and open the way for a new line. (I'm not talking about killing a running bash script, but just opening a new blank line) For no reason I can think of, this functionality just got turned off on a remote shell opened by SSH.

Ctrl+C will work on most other cases (like killing a running script, exiting VIM insert mode) but will no longer skip the line and go to the next on in the regular shell.

This is a shell running on Amazon linux 2, but I never had this issue on other Amazon Linux 2 machines, so it's probably coming from something I did...

Any idea what might have happened and how I can fix it ?

In the meantime I'm stuck pressing the delete key, which despite putting key repeat time to the minimum, is still quite slow.

EDIT -

I connect to the terminal using SSH, and this is interesting : if I open a new shell inside my SSH terminal (using bash) then CTRL+C works again !

社区高分解答

原帖链接 · kenlukas · CC BY-SA 4.0

To fix it you can use the stty command to reset it.

$ stty intr \^c

To see what intr is currently set you can use:

$ stty -a 

$ stty -a

speed 38400 baud; rows 21; columns 161; line = 0; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = M-^?; eol2 = M-^?; swtch = ; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0; -parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff -iuclc ixany imaxbel iutf8 opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0 isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke

The function of intr is described in the man page as:

intr CHAR

CHAR will send an interrupt signal

https://linux.die.net/man/1/stty

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-09-03)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。