!!! Bookmark Alert – Bookmark First for a Better Experience !!!
When I first started with the Raspberry Pi, navigating the command line in Linux was quite frustrating. After entering a long command, I realized I didn’t have the necessary permissions, and had to move the cursor back to the start of the line… Once I learned the keyboard shortcuts for the command line, not only did my efficiency improve, but I also started to enjoy this method of operation.
Commonly Used
-
Ctrl+Left/Right Arrow: Jump between words
-
Ctrl+a: Move to the beginning of the line
-
Ctrl+e: Move to the end of the line
-
Ctrl+u: Delete text before the cursor (also has cut functionality)
-
Ctrl+k: Delete text after the cursor (also has cut functionality)
-
Ctrl+L: Clear the screen
-
Ctrl+y: Paste content cut from Ctrl+u or Ctrl+k
-
Ctrl+w: Delete the word before the cursor
-
Alt-d: Delete the word from the cursor to the end of the line
Notes
-
Ctrl-k: Press and hold the Ctrl key, then press k;
-
Alt-k: Press and hold the Alt key, then press k;
-
M-k: Press Esc, then press k.
Cursor Movement
-
Ctrl-a: Move to the beginning of the line
-
Ctrl-e: Move to the end of the line
-
Ctrl-b: Move back (left) one character
-
Ctrl-f: Move forward (right) one character
-
Alt-b: Move back (left) one word
-
Alt-f: Move forward (right) one word
-
Ctrl-xx: Move between the end of the command line and the cursor
-
M-b: Move back (left) one word
-
M-f: Move forward (right) one word
Editing Commands
-
Ctrl-h: Delete the character to the left of the cursor
-
Ctrl-d: Delete the character to the right of the cursor (Note: If there are no characters in the command line, it will exit the system or terminate the terminal)
-
Ctrl-w: Delete the word to the left of the cursor
-
Alt-d: Delete the word to the right of the cursor
-
M-d: Delete the word from the cursor to the end of the word.
-
Ctrl-k: Delete all characters to the right of the cursor until the end of the line.
-
Ctrl-u: Delete all characters to the left of the cursor until the beginning of the line.
-
Ctrl-y: Paste previously deleted content after the cursor.
-
Ctrl-t: Swap the character at the cursor with the character before it.
-
Alt + .: Use the last parameter of the previous command.
-
Ctrl-_: Undo the previous action.
<span>Ctrl -a + Ctrl -k</span>
or <span>Ctrl -e + Ctrl -u</span>
or <span>Ctrl -k + Ctrl -u</span>
combinations can delete an entire line.
Bang(!) Commands
-
!!: Execute the last command.
-
^foo^bar: Replace foo with bar in the last command and execute it.
-
!wget: Execute the most recent command starting with wget.
-
!wget:p: Print the most recent command starting with wget without executing it.
-
!$: The last parameter of the previous command, same as
<span>Alt - .</span>
and<span>$_</span>
. -
!*: All parameters of the last command
-
!*:p: Print all parameters of the last command, which is the same as
<span>!*</span>
. -
^abc: Remove abc from the last command.
-
^foo^bar: Replace foo with bar in the last command
-
^foo^bar^: Replace foo with bar in the last command
-
!-n: Execute the last n commands, executing the last command:
<span>!-1</span>
, executing the last 5 commands is:<span>!-5</span>
Searching Command History
-
Ctrl-p: Show the previous command in the command history
-
Ctrl-n: Show the next command in the command history
-
Ctrl-r: Search the command history, showing a matching command as you type; press Enter to execute the matching command; press ESC to display the matching command without executing it.
-
Ctrl-g: Exit history search mode (Ctrl-r).
Control Commands
-
Ctrl-l: Clear the screen, then display the current line at the top of the screen.
-
Ctrl-o: Execute the current command and select the previous command.
-
Ctrl-s: Stop screen output
-
Ctrl-q: Allow screen output
-
Ctrl-c: Terminate the command
-
Ctrl-z: Suspend the command
Repeating Actions
-
M-Number Action: Specify the number of times to repeat the specified action.
Links in the text can be clicked to read the original article at the end
More Exciting Content
Let’s DIY a hot piece of equipment: Flame Throwing Gauntlet
Step-by-step Guide to “Producing” Arduino Nano
Raspberry Pi DIY 180-degree Ball Tracking Camera
DIY Wi-Fi Remote Control Boat with ESP32 Development Board
Create a Schedule Clock with Google Calendar using Raspberry Pi
Let’s make a “Infinity Mirror” with a magical style
TensorFlow 1.9 now officially supports Raspberry Pi!