常用的linux 终端快捷键
ctrl + a:移动光标至行头
ctrl + e:移动光标至行尾
ctrl + u: Cut/delete the Line before the cursor to the clipboard. 清除光标到行头的字符
ctrl + k: Cut the Line after the cursor to the clipboard. 清除光标到行尾的字符
ctrl + r:输入若干字符,开始向上搜索包含该字符的命令,继续按Ctrl+r,搜索上一条匹配的命令
ctrl + c:Interrupt/Kill whatever you are running (SIGINT);比如输完一个命令后,ctrl + c不执行该命令;或者命令正在执行的过程中,发送SIGINT 杀死进程;
ctrl + z:Send the signal SIGTSTP to the current task, which suspends it.
To return to it later enter fg ‘process name’ (foreground).
将您正在运行的所有程序置于暂停的后台进程中(类似于bg:backgroud)。 fg(frontgroud)恢复它
ctrl + w: 删除光标左边的一个单词;
tab: 补全;
alt(option) + 左移:光标往左边移动一个单词;
alt(option) + 右移:光标往右边边移动一个单词;
Alt + b 不删除命令的情况下,向前移动一个单词 Back (left) one word
Alt + f 向后一个单词 Forward (right) one word
Ctrl + y Paste the last thing to be cut (yank); 一般 ctrl + u/k, 然后 ctrl + y 可以将剪贴出来;
参见: http://einverne.github.io/post/2015/09/bash-learning-notes.html
linux 终端快捷键说明
Ctrl + A | Go to the beginning of the line you are currently typing on; 移动光标至行头 |
Ctrl + E | Go to the end of the line you are currently typing on;移动光标至行尾 |
Ctrl + L | Clears the Screen, similar to the clear command |
Ctrl + U | Clears the line before the cursor position. If you are at the end of the line, clears the entire line. 清除光标到行头的字符 |
Ctrl + H | Same as backspace |
Ctrl + R | Let's you search through previously used commands;输入若干字符,开始向上搜索包含该字符的命令,继续按Ctrl+r,搜索上一条匹配的命令 |
Ctrl + C | Kill whatever you are running; |
Ctrl + D | Exit the current shell |
Ctrl + Z | Puts whatever you are running into a suspended background process. fg restores it. |
Ctrl + W | Delete the word before the cursor; 删除光标左边的一个单词; |
Ctrl + K | Clear the line after the cursor;清除光标到行尾的字符 |
Ctrl + T | Swap the last two characters before the cursor |
Esc + T | Swap the last two words before the cursor |
Alt + F | Move cursor forward one word on the current line |
Alt + B | Move cursor backward one word on the current line |
Tab | Auto-complete files and folder names |
ctrl + r 反向查找
背景
在Linux系统下一直用上下键查找以前输入的命令,这个找刚输入不久的命令还是很方便的,但是比较久远的命令,用上下键效率就不高了。那个history命令也是个花架子,虽然功能多,但不好用,网上找了下,发现了用ctrl + r这个快捷键查找历史命令,研究了一下发现真是好用。
用途
反向搜索执行过的命令。(reverse-i-search)
使用
按下这个快捷键后,进入了反向搜索状态,这时你输入一个字符,系统会找到最近一个包含这个字符的命令,如果不是你想要的命令,你可以继续输入,系统继续查找最近一个包含你所输入的字符串的命令,直到找到你要的命令。
找到你想要的命令后,你可以按回车执行这条命令,还可以按上下键查找该命令前后的命令,按左右键移动光标并修改这条命令。继续按Ctrl+r,搜索上一条匹配的命令
ctrl + s 屏幕冻结
程序运行时,终端可能输出大量的日志,你想简单查看一下,又不想记录日志文件,此时可以使用ctrl+s键,冻结屏幕,使得日志不再继续输出,而如果想要恢复,可使用ctrl+q退出冻结。
ctrl + z
将您正在运行的所有程序置于暂停的后台进程中。 fg恢复它。
例如我们使用
$ cat filename
当我们发现文件内容可能很多时,使用ctrl+z暂停程序,而如果又想要从刚才的地方继续执行,则只需要使用fg命令即可恢复执行。或者使用bg使得进程继续在后台执行。
ctrl + c