Linux Shell 快捷键

来源:互联网 发布:新东方英语网络课程 编辑:程序博客网 时间:2024/04/29 20:08


Ctrl + a 可以快速切换到命令行开始处
Ctrl + e 切换到命令行末尾
Ctrl + r 在历史命令中查找
Ctrl + u 删除光标所在位置之前的所有字符
Ctrl + k 删除光标所在位置之后的所有字符
ctrl + w 删除光标之前的一个单词
Ctrl + d 结束当前输入、退出shell
ctrl + s 可用来停留在当前屏 ctrl + q 恢复刷屏
ctrl + l 清屏

CTRL 键相关的快捷键:

Ctrl + a - Jump to the start of the lineCtrl + b - Move back a charCtrl + c - Terminate the command  //用的最多了吧?Ctrl + d - Delete from under the cursorCtrl + e - Jump to the end of the lineCtrl + f - Move forward a charCtrl + k - Delete to EOLCtrl + l - Clear the screen  //清屏,类似 clear 命令Ctrl + r - Search the history backwards  //查找历史命令Ctrl + R - Search the history backwards with multi occurrenceCtrl + u - Delete backward from cursor // 密码输入错误的时候比较有用Ctrl + xx - Move between EOL and current cursor positionCtrl + x @ - Show possible hostname completions Ctrl + z - Suspend/ Stop the command补充:Ctrl + h - 删除当前字符Ctrl + w - 删除最后输入的单词 

ALT 键相关的快捷键:

平时很少用。有些和远程登陆工具冲突。

Alt + < - Move to the first line in the historyAlt + > - Move to the last line in the historyAlt + ? - Show current completion listAlt + * - Insert all possible completionsAlt + / - Attempt to complete filenameAlt + . - Yank last argument to previous commandAlt + b - Move backwardAlt + c - Capitalize the wordAlt + d - Delete wordAlt + f - Move forwardAlt + l - Make word lowercaseAlt + n - Search the history forwards non-incrementalAlt + p - Search the history backwards non-incrementalAlt + r - Recall commandAlt + t - Move words aroundAlt + u - Make word uppercaseAlt + back-space - Delete backward from cursor 
// SecureCRT 如果没有配置好,这个就很管用了。

其他特定的键绑定:

输入 bind -P 可以查看所有的键盘绑定。这一系列我觉得更为实用。

Here "2T" means Press TAB twice$ 2T - All available commands(common) //命令行补全,我认为是 Bash 最好用的一点 $ (string)2T - All available commands starting with (string)$ /2T - Entire directory structure including Hidden one$ ./2T - Only Sub Dirs inside including Hidden one$ *2T - Only Sub Dirs inside without Hidden one$ ~2T - All Present Users on system from "/etc/passwd" //第一次见到,很好用$ $2T - All Sys variables //写Shell脚本的时候很实用$ @2T - Entries from "/etc/hosts"  //第一次见到$ =2T - Output like ls or dir //好像还不如 ls 快捷补充:Esc + T - 交换光标前面的两个单词