admin 管理员组

文章数量: 887021


2024年1月22日发(作者:好听不撞的女生英文名)

Linux系统下Shell命令行快捷键实用技巧

2009-01-22 14:01

##注:以下字母不分大小写

# 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 xx - Move between EOL and current cursor position

光标在当前行的开头和结尾切换

# Ctrl L - Clears the Screen, similar to the clear command

清屏,类似于 clear 命令

---------------------------------------

# Ctrl U - Clears the line before the cursor position. If you are at the

end of the line, clears the entire line.

清除光标以前

# Ctrl K - Clear the line after the cursor

清除光标之后的所有内容。

---------------------------------------

# Ctrl H - Same as backspace

退格键 backspace

---------------------------------------

# Alt F - Move cursor forward one word on the current line

光标向前移动一个词的距离

# Alt B - Move cursor backward one word on the current line

光标向后移动一个词的距离

---------------------------------------

在图形界面下使用终端时会与Alt+F(打开file菜单)冲突,可以在 keyboard

Shortcuts选项中禁用file菜单项,即 (x)Disable all menu access keys(such

as Alt+f to open File menu)

这样就可以用shell自身的shortcuts了。

# Ctrl R - Let’s you search through previously used commands

从命令历史中找

# Ctrl C - Kill whatever you are running

终止命令

# Ctrl D - Exit the current shell

退出 shell

# Ctrl Z - Puts whatever you are running into a suspended background

process. fg restores it.

这个指你想中断一下当前执行的程序,但又不想杀死它,可以把它放到后台,想继续执行时,用fg可以唤醒它。

eg:

[test@localhost hyang0]$ du -sh autorun/

[2]+ Stopped du -sh autorun/

[test@localhost hyang0]$ su root

Password:

[root@localhost hyang0]# ifconfig

eth0 Link encap:Ethernet HWaddr 00:0C:29:45:58:3E

inet addr:128.224.158.134 Bcast:128.224.159.255

Mask:255.255.254.0

inet6 addr: fe80::20c:29ff:fe45:583e/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

RX packets:145934400 errors:3054 dropped:5782 overruns:0

frame:0

TX packets:158380695 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:4270079759 (3.9 GiB) TX bytes:1002567064 (956.1 MiB)

Interrupt:59 Base address:0x2000

lo Link encap:Local Loopback

inet addr:127.0.0.1 Mask:255.0.0.0

inet6 addr: ::1/128 Scope:Host

UP LOOPBACK RUNNING MTU:16436 Metric:1

RX packets:2202 errors:0 dropped:0 overruns:0 frame:0

TX packets:2202 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:0

RX bytes:3258635 (3.1 MiB) TX bytes:3258635 (3.1 MiB)

[root@localhost hyang0]# exit

exit

[test@localhost hyang0]$ fg

du -sh autorun/

---------------------------------------

# Ctrl W - Delete the word before the cursor

清除光标之前的一个词,一般是以空格格开,不会删一行。

# Alt d - Delete word

向后删一个词

---------------------------------------------

# Ctrl T - Swap the last two characters before the cursor

交换光标前的最后两个字符

# Esc T - Swap the last two words before the cursor

交换光标前的最后两个单词

# Tab - Auto-complete files and folder names

自动补全

# Ctrl Y - to paste it (as in delete and copy) all text in front of the

cursor

粘贴(刚才 ctrl w 或者 ctrl k 的内容)

# Esc . (or Esc Underscore) - Insert Last Argument

插入最后一个参数,

比如我 运行 $ cd /

那么我执行“ Esc . ”, 就会插入 "/ " 这个参数

-------------------------------------

# Ctrl b - Move back a character

# Ctrl f - Move forward a character

将光标向前|后移动一个字母的距离,不改变任何东西。

--------------------------------------

# Ctrl x @ - Show possible hostname completions

# Alt

# Alt > - Move to the last line in the history

# Alt ? - Show current completion list

# Alt * - Insert all possible completions

# Alt / - Attempt to complete filename

# Alt . - Yank last argument to previous command

# Alt c - Capitalize the word

# Alt l - Make word lowercase

# Alt n - Search the history forwards non-incremental

# Alt p - Search the history backwards non-incremental

# Alt r - Recall command

# Alt t - Move words around

# Alt u - Make word uppercase

# Alt back-space - Delete backward from cursor

# Here "2T" means Press TAB twice

# $ 2T - All available commands(common)

# $ (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

# $ @2T - Entries from "/etc/hosts"

# $ =2T - Output like ls or dir


本文标签: 光标 移动 命令行 好听 命令