Linux command line keyboard shortcuts

備份文件

cp install_collectd.log{,-old}

備份恢復(fù)

mv /etc/rc.conf{-old,}

重命名文件

mv /path/to/file.{txt,xml}

批量生成文件夾

mkdir myfolder{1,2,3}

光標移動到行首行尾

Ctrl+AandCtrl+E

刪除光標前光標后,刪除光標前的單詞

Ctrl+U Ctrl+K Ctrl+W

搜索歷史命令

Ctrl+R

回到上次目錄

cd - ?

回到用戶目錄

cd ~

if you run a command that needs root privileges but forget to addsudoto the beginning, there's no need to retype the command. Just run:

sudo !!

if you want to run the last command that usedcat, you could just type:

!cat

If you just want to see what the lastcatcommand was, you can instead run:

!cat:p

say you had just created a folder using:

mkdir /new/awesome/folder

To thencdinto that directory, you could just type:

cd !$

Ctrl+LClear the screen

tabTab key autocomplete the name of command/file/directory etc. For eg. typetouand type tab

UP ARROW KeyShows you previous command in descending order

DOWN Arrow KeyWhen you are usingUP ARROW Keyto get previous command.Then try thisDOWN Arrow,it will show forward command history

Ctrl+RIt is for Reverse search.Press CTRL+R and type some command which you last run.It will search for last command you run.

Here we pressed CTRL+r then typed /etc ,it automatically searched for command

(reverse-i-search)`/etc': /etc/init.d/httpd restart

Ctrl+JIt end the CTRL+r search

Ctrl+GIt abort the search by CTRL+r ( and restores original line)

CTRL+pIt shows previous history,same like UP arrow key

CTRL+nIt shows forward history,same like DOWN arrow key

Ctrl+BMove cursor one character to the left side

Ctrl+FMove cursor one character to the right side

Ctrl+AMove cursor to start of the line

Ctrl+EMove cursor to end of the line

HOMEMove cursor at the start of the line

ENDMove cursor at the end of the line

CTRL+ RIGHT ARROWMove cursor one word right hand side

CTRL + RIGHT ARROWMove cursor one word left hand side

Ctrl+UIt cut everything from the line start to cursor

Ctrl+KIt cut everything from the cursor to end of the line

Ctrl+WIt cut the current word before the cursor

Ctrl+YIt paste the previous cut text

CTRL+kIt cut the line from the position of the cursor to the end of the line.

CTRL+SHIFT+cTo copy selected text

CTRL+SHIFT+vTo paste you last copied by CTRL+SHIFT+c

SHIFT + INSERTCopy selected text to clipboard and paste from the clipboard

Shift+PgUp/PgDown It Scrolls console buffer up/down. You can use this key, also in Runlevel 3 or terminal mode

CTRL+zPut the running process in background.(To get back, runjobscommand.And then foregorund it by usingfgcommand. )

For example. First run thetopthen press CTRL+z.After this use fg command and found job no. 1 for top. See below example

linux@tuxworld:~/Desktop$jobs[1]+Stoppedtoplinux@tuxworld:~/Desktop$fg%1

Ctrl + TIt swap the last two characters before the cursor

Esc + TIt swap the last two words before the cursor

CTRL+mIt is like a Enter key (If ENTER key do not work,try this)

And at the end….

Ctrl + DLog out of current session, likeexitcommand

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容